I have a script that creates a video from images on the server and let's the user download the video. After the video is downloaded the script removes the video file from the server.

When the video file is being downloaded the header content-length gives the correct file size with file size() function. But after or during the file download, if the user clicks any link on the website he gets the file size() stat failed error.

Here's the code:

exec('/usr/bin/mencoder "mf://' . $images . '" -mf fps=25 -o ' . $outputvideo . ' -ovc lavc -lavcopts vcodec=mjpeg:vbitrate=800');

if (file_exists($outputvideo)){
header('Content-Type: video/x-msvideo');
header('Content-Disposition: attachment; filename=' . $outputfilename . '');
header('Content-Length: ' . filesize($outputfilename));
ob_clean();
readfile($outputvideo);
unlink($outputvideo);
exit();
}
有帮助吗?

解决方案

I was able to fix this by commenting out / removing the following line:

header('Content-Length: ' . filesize($outputfilename));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top