使用XMLHttpRequest上传大文件时发生PHP错误

编程入门 行业动态 更新时间:2024-10-24 06:30:29
本文介绍了使用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错误

本文发布于:2023-11-01 12:27:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549330.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大文件   错误   发生   上传   XMLHttpRequest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!