2012-05-28 69 views
5

我一直在使用PHP脚本将数据从我的数据库(mysql)导出到XLS文件。使用PHP导出XLS文件时的Google Chrome错误

尽管文件导出过程在Firefox和IE上运行良好。

尝试使用Google Chrome进行导出时出现错误。

谷歌Chrome的错误是

Duplicate headers received from server 

The response from the server contained duplicate headers. This problem is generally the result of a misconfigured website or proxy. Only the website or proxy administrator can fix this issue. 

Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple distinct Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks. 

我需要在此方面的援助。

感谢

+0

HTTP响应头有问题。使用[Fiddler](http://fiddler2.com)捕获HTTP头并将其发布到此处。 – flowfree

+0

发生在我身上。通过从文件名中删除逗号来修复它 –

+0

另一个答案改变'header(“Content-Disposition:attachment; filename = {$ file}”);'to header(“Content-Disposition:attachment; filename = \”{$文件} \“”);' –

回答

9

我发现了什么我的问题是在PHP代码出口的开头部分。不正确的和正确的路线如下:

不正确

header("Content-Disposition: attachment;filename=\"".$this->filename."\""); 

正确

header("Content-Disposition: attachment; filename=\"".$this->filename."\""); 

校正感附件之间增加的空间;文件名

希望这会有所帮助。

3

我有这个相同的问题。但是很少出现。原因相似但不完全相同。

错误

header("Content-Disposition: attachment; filename=$filename"); 

正确

header("Content-Disposition: attachment; filename=\"$filename\""); 

$文件名有时处于包含导致mentionec Chrome的误差空间。

1

我也遇到了同样的问题。在下载名称中包含逗号的文件时,它会说“收到了重复标题”,并且仅在chrome中显示。在Firefox中,它是确定的。之后,我只是将我的代码从
header("Content-Disposition: attachment; filename=$myfilename");更改为 header("Content-Disposition: attachment; filename=\"$myfilename\"");,它工作正常。希望它能为你工作。