PHP大型报告文件下载问题

发布于 2024-08-04 16:01:01 字数 513 浏览 1 评论 0 原文

已解决

我实际上发现了这里发生的事情。

结果它发送了整个文件,但 Excel(我用来打开结果文件进行测试)只会显示 65536 行。如果多了,就会提示“文件显示不完整”,然后在多条记录后将其切断。

(Joel Spolsky 请注意 - 请给原来 Excel 开发团队的朋友打电话,帮我对他们大喊大叫 =o)

谢谢!


我有一个非常简单的脚本,它从数据库中提取一些数据,并将其作为 .csv 文件发送给访问者。

我将内存和执行时间设置为可接受的水平,但对于一些大型报告,我注意到下载在大约 10 秒后停止。

仅当我在标题中将其设置为下载时才会发生这种情况。如果我注释掉内容类型、内容处置等,然后将数据写入浏览器,那么整个文件将下载并显示在浏览器中。

代码如下:

// Code removed.

大家有什么想法吗?这可能是文件下载的浏览器问题吗?

谢谢!

Solved

I actually found out what is going on here.

Turns out it was sending the whole file, but Excel (which I was using to open the result file for testing), will only display 65536 rows. If there are more than that, it will alert something to the effect of "the file is incompletely displayed" and then cut it off after that many records.

(Note to Joel Spolsky - please call your friends from the original Excel development team and yell at them for me =o)

Thanks!


I have a very simple script that pulls some data from a database, and sends it to the visitor as a .csv file.

I have the memory and execution time set to acceptable levels, but for a few large reports, I notice that the download cuts off after about 10 seconds.

This ONLY happens if I set it as a download in the headers. If I comment out the content-type, content-disposition, etc, and just write the data to the browser, then the entire file will download and display in the browser.

Code is as follows:

// Code removed.

Anyone have any ideas? Could this be a browser issue with file download?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

度的依靠╰つ 2024-08-11 16:01:01

我不知道是什么导致了您的问题,但您可以尝试以下操作:

将数据写入文件,然后使用 X-Sendfile 将其发送给用户(请参阅 这个)标题。或者,您可以重定向到该文件。

I don't know what's causing your problem, but here is something that you can try:

Write the data to a file and then send it to the user using the X-Sendfile(see this) header. Alternatively you can redirect to the file.

永不分离 2024-08-11 16:01:01

我有一个稍微类似的问题,但下载速度非常慢。罪魁祸首是一个过于激进的防病毒软件包,仅影响 IE 下载。检查 Mcshield.exe。

I had a slightly similar issue, but with very slow downloads. The culprit was an overly aggressive antivirus package affecting only IE downloads. Check for Mcshield.exe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文