I am using a php script to force-download video files of average size 100-150 MB. Now every time i download a file 4KB sized file is getting downloaded. Do i need to do changes in php.ini? Any other change required.
Current php.ini config:
upload_max_filesize = 400M
post_max_size=500M
default_socket_timeout = 60000
output_buffering= On
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
$myfile = "http://localhost/project/".$_POST['file'];
// Add bellow code for mime type
$ext=strtolower(substr($fl,strrpos($myFile,".")));
$mime_types = array(
// video
'.3gp' => 'video/3gpp',
'.3g2' => 'video/3g2',
'.avi' => 'video/avi',
'.mp4' => 'video/mp4',
'.asf' => 'video/asf',
'.mov' => 'video/quicktime',
);
if (array_key_exists($ext, $mime_types)){
$mm_type=$mime_types[$ext];
}
else{
$mm_type="application/octet-stream";
}
header("Pragma: public");
header("Content-Type: " . $mm_type);
header('Content-Disposition: attachment; filename='.basename($myfile));
header('Content-Length: ' . filesize($myFile));
header("Content-Transfer-Encoding: binary");
ob_clean();
readfile($myFile);
RESOLVED: at the last two places $myFile was used instead of $myfile. Thanks All. Thanks Pekka the 4kb files were errors had to convert them to html to read them.