本文介绍了使用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错误
发布评论