如何以php的大小下载文件
我应该在本地PC驱动器中下载带有200MB的大文件视频。
该代码对于中等大小是正确的,但大尺寸失败,返回err_invalid_response。
我也尝试使用readfile和file_get_contents方法,而无需成功。
我的代码php是:
<?php
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=a.mp4");
Header("Content-Description: Download Manager");
header('Content-Transfer-Encoding: binary');
Header("Pragma: No-Cache");
Header("Expires: 0");
ob_clean();
$path="http://myurlexample/...../a.mp4"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch) === FALSE) {
echo "Error: " . curl_error($ch);
} else {
echo curl_exec($ch);
}
curl_close($ch);
flush();
exit();
?>
I should download Big file video with size 200mb in local pc drive.
The code is correct for medium size but fail with big size with return ERR_INVALID_RESPONSE.
I have tried also with readfile and file_get_contents method without succesfull.
My code php is:
<?php
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=a.mp4");
Header("Content-Description: Download Manager");
header('Content-Transfer-Encoding: binary');
Header("Pragma: No-Cache");
Header("Expires: 0");
ob_clean();
$path="http://myurlexample/...../a.mp4"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $path);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch) === FALSE) {
echo "Error: " . curl_error($ch);
} else {
echo curl_exec($ch);
}
curl_close($ch);
flush();
exit();
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论