doudou2121
doudou2121
采纳率50%
2013-06-30 19:33 阅读 49
已采纳

用户退出页面时,PHP filesize stat失败

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();
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    doushao1948 doushao1948 2014-06-03 17:38

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

    header('Content-Length: ' . filesize($outputfilename));
    
    点赞 评论 复制链接分享

相关推荐