Horje
How to get file size from a remote url in PHP

Here I make a simple code.


Full Example of Extract File Size from url

Follow the Example.
index.php
Example: PHP
<?php
function fsize($path) { 
      $fp = fopen($path,"r"); 
      $inf = stream_get_meta_data($fp); 
      fclose($fp); 
      foreach($inf["wrapper_data"] as $v) { 
        if (stristr($v, "content-length")) { 
          $v = explode(":", $v); 
          return trim($v[1]); 
        } 
      } 
      return 0;
    } 
?>

<?php
$file = "https://downloads.wordpress.org/plugin/wordpress-seo.22.6.zip"; 
$inbytes = fsize($filesize);
echo $inbytes;
?>

Output should be:






Related Articles
How to add PHP File Get Content PHP URL/LINK Tutorial
How to add PHP cURL CURLOPT PHP URL/LINK Tutorial
How to load XML Sitemap URLs PHP URL/LINK Tutorial
How to get file size from a remote url in PHP PHP URL/LINK Tutorial
How to create a zip file from url using PHP PHP URL/LINK Tutorial


Read Full:
PHP URL/LINK Tutorial
Category:
Web Tutorial
Sub Category:
PHP URL/LINK Tutorial
Uploaded by:
Admin
Views:
111


Reffered: https://stackoverflow.com/questions/52368541/how-to-find-the-file-size-by-url-in-php-script