(413)文件上传PHP期间请求实体太大错误

编程入门 行业动态 更新时间:2024-10-26 20:21:28
本文介绍了(413)文件上传PHP期间请求实体太大错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正面临与PHP文件上传相关的问题.我正在尝试使用AJAX提交表单.此ajax请求包含文本变量和文件.当我尝试仅发送一个文件时,则一切正常,但是如果我要发送多个文件.我收到 413请求实体太大错误.我正在使用Apache.这是我的代码

I am facing a problem which is related to PHP file upload . I am trying to submit a form using AJAX . This ajax request contains text variables and file(s) . When I am trying to send only one file then everything is going okay but in case I am sending more than one file. I am getting 413 Request Entity Too Large error . I am using Apache . Here is my code

const data = new FormData(); data.append('name', 'my upload file'); for (const i = 1; i <= 4; i++) { const img = $(`#src${i}`).find('img').attr('src'); data.append(`image${i}`, img || ''); } $.ajax({ type: "POST", url: "server.php", data: data, cache: false, processData: false, contentType: false, success: (result) => { console.log(1); } });

我所有上传的文件都小于700KB,我还使用ini_get_all()检查了PHP配置,发现post_max_size为48MB,upload_max_filesize为32MB.我不明白是什么原因造成了这个问题.

All my uploaded files are lesser than 700KB , I also checked the PHP configuration using ini_get_all() and I found that post_max_size is 48MB , upload_max_filesize is 32MB . I am not getting that what is the reason for that problem .

要检查我是否超出了允许的上传限制,我添加了四个文件(每个文件大小为10KB),但是当我能够发送一个400KB的文件时,它也会产生相同的问题.有什么方法可以确定此问题的根本原因.

To check that whether I am exceeding the allowed upload limit , I added four files (each with 10KB) but it also generating same problem while I am able to send one file of 400KB . Is there any way to identify the root cause of this problem.

推荐答案

您需要将您的nginx conf(/usr/local/nginx/conf/nginx.conf)设置更改为此

You need to change your nginx conf (/usr/local/nginx/conf/nginx.conf) setting to this

client_max_body_size 512M;//set it to higher mb

设置此值后,您需要重新启动Nginx

After setting this value you would need to restart nginx

service nginx restart

更多推荐

(413)文件上传PHP期间请求实体太大错误

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

发布评论

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

>www.elefans.com

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