doudou2121 2013-06-30 19:33 采纳率: 50%
浏览 75
已采纳

用户退出页面时,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 2014-06-03 17:38
    关注

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

    header('Content-Length: ' . filesize($outputfilename));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何实验stm32主通道和互补通道独立输出
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题