src/Helper.php
public static function remotefsize($url)
	{
		$sch = parse_url($url, PHP_URL_SCHEME);

		if (!\in_array($sch, array('http', 'https', 'ftp', 'ftps'), true))
		{
			return false;
		}

		if (\in_array($sch, array('http', 'https'), true))
		{
			$headers = @ get_headers($url, 1);

			if (!$headers || (!array_key_exists('Content-Length', $headers)))
			{
				return false;
			}

			return $headers['Content-Length'];
		}

		if (\in_array($sch, array('ftp', 'ftps'), true))
		{
			$server = parse_url($url, PHP_URL_HOST);
			$port   = parse_url($url, PHP_URL_PORT);
			$path   = parse_url($url, PHP_URL_PATH);
			$user   = parse_url($url, PHP_URL_USER);
			$pass   = parse_url($url, PHP_URL_PASS);

			if ((!$server) || (!$path))
			{
				return false;
			}

			if (!$port)
			{
				$port = 21;
			}

			if (!$user)
			{
				$user = 'anonymous';
			}

			if (!$pass)
			{
				$pass = '';
			}

			$ftpid = null;

			switch ($sch)
			{
				case 'ftp':
					$ftpid = @ftp_connect($server, $port);

					break;

				case 'ftps':
					$ftpid = @ftp_ssl_connect($server, $port);

					break;
			}

			if (!$ftpid)
			{
				return false;
			}

			$login = @ftp_login($ftpid, $user, $pass);

			if (!$login)
			{
				return false;
			}

			$ftpsize = ftp_size($ftpid, $path);
			ftp_close($ftpid);

			if ($ftpsize == -1)
			{
				return false;
			}

			return $ftpsize;
		}
	}
public static function remotefsize($url)
	{
		$sch = parse_url($url, PHP_URL_SCHEME);

		if (!\in_array($sch, array('http', 'https', 'ftp', 'ftps'), true))
		{
			return false;
		}

		if (\in_array($sch, array('http', 'https'), true))
		{
			$headers = @ get_headers($url, 1);

			if (!$headers || (!array_key_exists('Content-Length', $headers)))
			{
				return false;
			}

			return $headers['Content-Length'];
		}

		if (\in_array($sch, array('ftp', 'ftps'), true))
		{
			$server = parse_url($url, PHP_URL_HOST);
			$port   = parse_url($url, PHP_URL_PORT);
			$path   = parse_url($url, PHP_URL_PATH);
			$user   = parse_url($url, PHP_URL_USER);
			$pass   = parse_url($url, PHP_URL_PASS);

			if ((!$server) || (!$path))
			{
				return false;
			}

			if (!$port)
			{
				$port = 21;
			}

			if (!$user)
			{
				$user = 'anonymous';
			}

			if (!$pass)
			{
				$pass = '';
			}

			$ftpid = null;

			switch ($sch)
			{
				case 'ftp':
					$ftpid = @ftp_connect($server, $port);

					break;

				case 'ftps':
					$ftpid = @ftp_ssl_connect($server, $port);

					break;
			}

			if (!$ftpid)
			{
				return false;
			}

			$login = @ftp_login($ftpid, $user, $pass);

			if (!$login)
			{
				return false;
			}

			$ftpsize = ftp_size($ftpid, $path);
			ftp_close($ftpid);

			if ($ftpsize == -1)
			{
				return false;
			}

			return $ftpsize;
		}
	}
public static function remotefsize ( $ url ) { $ sch = parse_url ( $ url , PHP_URL_SCHEME ) ; if ( ! \ in_array ( $ sch , array ( 'http' , 'https' , 'ftp' , 'ftps' ) , true ) ) { return false ; } if ( \ in_array ( $ sch , array ( 'http' , 'https' ) , true ) ) { $ headers = @ get_headers ( $ url , 1 ) ; if ( ! $ headers || ( ! array_key_exists ( 'Content-Length' , $ headers ) ) ) { return false ; } return $ headers [ 'Content-Length' ] ; } if ( \ in_array ( $ sch , array ( 'ftp' , 'ftps' ) , true ) ) { $ server = parse_url ( $ url , PHP_URL_HOST ) ; $ port = parse_url ( $ url , PHP_URL_PORT ) ; $ path = parse_url ( $ url , PHP_URL_PATH ) ; $ user = parse_url ( $ url , PHP_URL_USER ) ; $ pass = parse_url ( $ url , PHP_URL_PASS ) ; if ( ( ! $ server ) || ( ! $ path ) ) { return false ; } if ( ! $ port ) { $ port = 21 ; } if ( ! $ user ) { $ user = 'anonymous' ; } if ( ! $ pass ) { $ pass = '' ; } $ ftpid = null ; switch ( $ sch ) { case 'ftp' : $ ftpid = @ ftp_connect ( $ server , $ port ) ; break ; case 'ftps' : $ ftpid = @ ftp_ssl_connect ( $ server , $ port ) ; break ; } if ( ! $ ftpid ) { return false ; } $ login = @ ftp_login ( $ ftpid , $ user , $ pass ) ; if ( ! $ login ) { return false ; } $ ftpsize = ftp_size ( $ ftpid , $ path ) ; ftp_close ( $ ftpid ) ; if ( $ ftpsize == - 1 ) { return false ; } return $ ftpsize ; } }
Remote file size function for streams that don't support it

@param   string  $url  TODO Add text

@return  mixed

@link    https://www.php.net/manual/en/function.filesize.php#71098
@since   1.0
Remote file size function for streams that don t support it