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
Post a Comment