Please help to see this php download MP4 file problem, the file download is not complete
function Dl_file ($file) {
$len = FileSize ($file);
$filename = basename ($file);
$file _extension = Strtolower (substr (STRRCHR ($filename, "."), 1);
Switch ($file _extension) {
Case "mp4": $ctype = "Video/mp4"; Break
Default: $ctype = "Application/force-download";
}
Header ("Pragma:public");
Header ("expires:0");
Header ("Cache-control:must-revalidate, Post-check=0, pre-check=0");
Header ("Content-description:file Transfer");
Header ("Content-type: $ctype");
$header = "content-disposition:attachment; Filename= ". $filename.";
Header ($header);
Header ("Content-transfer-encoding:binary");
Header ("Content-length:". $len);
Ob_clean ();
Flush ();
ReadFile ($file);
Exit
}
Dl_file (' Test.mp4 ');
In Firefox, Google browser download normal, ie and thunder download file is not complete
------Solution--------------------
Ob_clean ();
Flush ();
ReadFile ($file);
------Solution--------------------
No MIME header
------Solution--------------------
Header ("Content-transfer-encoding:binary");
Header ("Content-length:". $len);
These two, try to erase it.
------Solution--------------------
Nginx + PHP environment Without you said that the problem, ie and thunder can be normal download but my file is flv, so it can only indicate that the MIME header error
My code is as follows:
function Dl_file ($file) {
$len = FileSize ($file);
$filename = basename ($file);
$file _extension = Strtolower (substr (STRRCHR ($filename, "."), 1);
Switch ($file _extension) {
Case "mp4": $ctype = "Video/mp4"; Break
Default: $ctype = "Application/force-download";
}
Header ("Pragma:public");
Header ("expires:0");
Header ("Cache-control:must-revalidate, Post-check=0, pre-check=0");
Header ("Cache-control:public");
Header ("Content-description:file Transfer");
Header ("Content-type: $ctype");
$header = "content-disposition:attachment; Filename= ". $filename.";
Header ($header);
Header ("Content-transfer-encoding:binary");
Header ("Content-length:". $len);
Ob_clean ();
Flush ();
ReadFile ($file);
Exit
}
Dl_file (' http://res.805.com/videos/Huo Shan * kanbayashi hou yuan (Yi Qian billion group) [640x480].flv '); Just changed one file name, and nothing else has changed.