PHP: Checking file size whilst downloading file to server -


the user provide url server fetch file using file_put_contents()

i restrict file size 1mb

i able check file size of files prior downloading using this solution. not every head request returns size of file prior download.

is there way stop download of file server if file size exceeds number of bites?

answer suggested sergiu paraschiv comments:

function get_file_name_from_url( $url, $sizelimit ) { $_1mb = 8000000; $limit = $_1mb *  $sizelimit; $file = fopen("$url","r"); fread($file,"$limit");  // check end of file if (feof($file)){     return true; } else{  //file big   return false; }  fclose($file); } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -