doumaojin4008 2015-04-28 21:40
浏览 326
已采纳

如何通过http标题下载mp4文件

I've got a mp4 file saved on external FTP server. When I save it over "Save video as" when I play this video in classic HTML5 player, everything is ok. But when I download this file over this headers:

header('Content-Description: File Download');
header('Content-Transfer-Encoding: binary');
header('Content-Length: FILE_SIZE');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
header('Expires: Mon, 1 Apr 1974 05:00:00 GMT');
header("Content-type: video/mp4");
header("Content-disposition: attachment; filename=FILE_NAME");
readfile(FILE_URL); // do the double-download-dance (dirty but worky)

(FILE_SIZE, FILE_URL and FILE_NAME are filled correctly of course), than mp4 file is downloaded, but every player say something like "this format is not supported". When i download any other filetype (pdf/ppt,...), everything is ok.

Any ideas, pls??

  • 写回答

1条回答 默认 最新

  • doutao6653 2015-04-28 23:37
    关注

    File 1 (Wrong File, Not able to play):

    http://www.vaseakademie.cz/ajax/s:lekceTools/c:lekceTools/m:getFile/loID:177

    Through 'Stáhnout lekci'

    Filesize: 50156182 MD5:ef0bf2fdfe1774c0a75d26202cdebdcd

    File 2 (Correct File, able to play):

    http://data.vaseakademie.cz/lekce/kurz_68/b55bf87383652751aeefd02f844f9fd9.mp4

    From the source if the playing video. Same with right click, save video as

    Filesize: 50156182 MD5:ef72631add8524d72ac1b61bacf0cc1a

    Conclusion:

    Nothing wrong with the header, the file content is different. You should check your script for file processing, not the header

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?