【问题标题】:Failed to load resource: Frame load interrupted - Agian加载资源失败:帧加载中断 - 再次
【发布时间】:2012-09-14 03:41:14
【问题描述】:

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

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

我的 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);

我有一个调用 iframe 来下载文件的 jQuery 脚本:

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

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

【问题讨论】:

    标签: php jquery


    【解决方案1】:
    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');
    

    这会起作用 ;-)

    【讨论】:

    • 感谢您的回复,Content-Length 大小是否重要.. 如果文件大于 177998 怎么办?
    • 将内容长度设置为您的实际内容长度..说实话 - 我实际上完全删除了内容长度并且脚本工作得很好。
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2016-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-14
      • 2012-07-24
      • 2018-01-15
      • 2013-02-26
      • 2019-05-28
      相关资源
      最近更新 更多