【问题标题】:PHP error when uploading large files with XMLHttpRequest使用 XMLHttpRequest 上传大文件时出现 PHP 错误
【发布时间】:2017-09-30 02:39:12
【问题描述】:

我使用 XMLHttpRequest 通过 PHP 上传文件, 这适用于小文件,但对于超过 15MB 的大文件,我收到此服务器错误:

**Failed to load resource: the server responded with a status of 502 (Broken pipe).**

我已提升所有上传参数:

**upload_max_filesize = 100M
post_max_size 100M
max_input_time 300000
max_execution_time 30000
memory_limit = 200M**

但问题仍然存在。

提前致谢

【问题讨论】:

  • 您是否也增加了网络服务器设置中的选项? (对于 nginx,它将是 client_max_body_size
  • 我不使用 nginx

标签: php file-upload xmlhttprequest


【解决方案1】:

您的请求超时,而不是 PHP。在发送请求之前增加超时限制。更多信息here

var xhr = new XMLHttpRequest();
xhr.open('GET', '/server', true);

xhr.timeout = 2000; // time in milliseconds

xhr.send(null);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-25
    • 2016-04-14
    • 2016-05-17
    • 2016-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多