我有从虚假链接下载图片的代码。我看过其他评论/网站但没有任何帮助我找到烦人的解决方案:
“无法加载资源:帧加载中断”
我的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>');
我正确下载文件,但在控制台中显示错误,请告诉我它是否可修复?
答案 0 :(得分: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');
这将有效; - )
答案 1 :(得分:0)
好的,通过与vimeo的convo,并确定问题是由于Content-Disposition:附件。他们告诉我这是一个继承浏览器的问题。您不应该使用不同的DNS来加载资源,因此它会起作用,但浏览器不会对此感到高兴。