正确的标题以下载mp4文件 [英] correct header to download an mp4 file
本文介绍了正确的标题以下载mp4文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里测试头文件功能,使我可以从浏览器下载mp4文件.我的文件大小为94兆字节.但是当我单击下载按钮时,我得到的文件长度仅为273 KB .这种情况可能是什么原因造成的,我该如何解决?
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>
推荐答案
尝试
header("Content-Type: video/mp4");
header("Content-Length: ".filesize("path/to/mp4"));
readfile("path/to/mp4");
这篇关于正确的标题以下载mp4文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文