سؤال

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