doufu8887
2016-09-10 19:42 阅读 134

正确的标题下载mp4文件

Here i am testing with header functions which will allow me to download a mp4 file from browser.I have a file which is 94 megabyte in size.But when i click the download button i get a file which is only 273 kilobyte long.What might be the reason behind this situation and how i can solve this ?

<?php

if(isset($_POST['mymp4'])){
    header('Content-Type: video/mp4');
    header('Content-Disposition: attachment; filename="'.$_POST['mymp4'].'"');
}
?>

<html>
<body>
<form action='<?php echo $_SERVER["PHP_SELF"]; ?>' method='POST'>
  <input type='hidden' value='Design Patterns for JavaScript Web Apps -- JavaScript Confer.mp4' name='mymp4'>
  <input type='submit' value='download mp4' />
</form>
</body>

</html>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • dongnaigu2052 dongnaigu2052 2016-09-10 20:22

    Try

    header("Content-Type: video/mp4");
    header("Content-Length: ".filesize("path/to/mp4"));
    readfile("path/to/mp4");
    
    点赞 9 评论 复制链接分享

相关推荐