使用XMLHttpRequest上传大文件时发生PHP错误 [英] PHP error when uploading large files with XMLHttpRequest

查看:85
本文介绍了使用XMLHttpRequest上传大文件时发生PHP错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  **无法加载资源:服务器响应状态为502(管道损坏).** 

我提高了所有上传参数:

  ** upload_max_filesize = 100Mpost_max_size 100Mmax_input_time 300000max_execution_time 30000memory_limit = 200M ** 

但是问题仍然存在.

预先感谢

解决方案

您的请求到达超时,而不是PHP.在发送请求之前增加超时限制.更多信息此处

  var xhr = new XMLHttpRequest();xhr.open('GET','/server',true);xhr.timeout = 2000;//时间(以毫秒为单位)xhr.send(null); 

i ame using XMLHttpRequest to upload file with PHP, this works fine with small files, but with large files over 15MB, i got this server error:

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

ihave boosted all upload parameters:

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

but the probleme persists.

Thanks in advance

解决方案

Your request reaches timeout, not PHP. Increase timeout limit before sending request. More info here

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

xhr.timeout = 2000; // time in milliseconds

xhr.send(null);

这篇关于使用XMLHttpRequest上传大文件时发生PHP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆