8

我有从假链接下载图片的代码。我查看了其他评论/网站,但没有什么能帮助我找到解决烦人的方法:

“加载资源失败:帧加载中断”

我的 php 标头是在我读取 GET 值之后:

header("Pragma: public"); // required 
header("Expires: 0"); 
header("Cache-Control: private",false); // required for certain browsers 
//header('Content-Length: '. @filesize($id));
header('Content-Type: '.$mim);
header('Content-Disposition: attachment; filename="'.$date.basename($fileName).'"');
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
readfile($fileName);

我有 jQuery 脚本,它调用 iframe 来下载文件:

$('body').append('<iframe class="download" src="download.php?id='+downloading+'" style="visibility:hidden;" width="0" height="0"></iframe>');

我正确下载了文件,但在控制台中显示错误,请告诉我它是否可以修复??

4

2 回答 2

2
header("Pragma: public"); // required
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Cache-Control: private",false); // required for certain browsers 
header("Content-type: application/x-unknown"); // I always use this
header("Content-Disposition: attachment; filename='theFilename.ext'");
header("Content-Transfer-Encoding: binary");
header("Content-Length: 177998"); // you might want to set this
readfile('/the/url/to/theFilename.ext');

这将起作用;-)

于 2012-09-12T12:32:54.727 回答
0

好的,所以通过与 vimeo 的 convo,并找出问题是由于 Content-Disposition: 附件。他们告诉我这是浏览器继承的问题。您不应该使用不同的 DNS 来加载资源,因此它会起作用,但浏览器不会对此感到满意。

于 2012-09-13T19:41:14.010 回答