Wordpress: 413 Request Entity Too Large - php

I have a WP site managed on an Ubuntu server with Plesk.
For a few hours I can not upload files above 2MB.
I have made several attempts like:
Change the settings from php.ini (verifying via phpinfo () that they were set correctly).
Both through Plesk and manually;
Change different PHP versions (from 5.6, 7.0.x, 7.1.x, to 7.2.x);
Disabled firewall;
Tested with different types and name files;
Set the upload limit with nginx (either manually or via plesk);
Tried to set the limit via .htaccess and / or wp-config;
Updated WP, ​​plugins and themes;
Disabled all plugins;
Try to decrease the upload limit to 1 MB (in this case it displayed the limit and did not allow me to proceed with the upload);
Tested by other PC / browsers.
On other sites uploaded to the same server, with the same settings (one is the backup of the site in question) instead I can correctly upload the files.
On the file upload screen I see the upload limit correctly (for example 64M) but if I upload a file greater than 2MB I see the error:
413 Request Entity Too Large
What could it be? Do you have any ideas / suggestions on this?
Thanks a lot!

Most probably that the reason of this issue is ModSecurity settings. Check solution from https://support.plesk.com/hc/en-us/articles/115001764933-Unable-to-edit-document-on-the-website-ModSecurity-Request-body-no-files-data-length-is-larger-than-the-configured-limit-

To fix, you need to set server block like this
server {
client_max_body_size 0;
...

Related

PHP - File uploading process resets

I'm trying to upload files over 150MB with a PHP file, which works without any problem with files less than 40Mb. But when I try to upload files like 150 to 200 MB, it resets the upload process after uploading about half of the file.
It repeats again and again when the new upload process gets to same value, till the time limits on php.ini file kills the process.
The first thing I tried was increasing those values in my php.ini file:
post_max_size=450M
memory_limit=300M
max_execution_time=1600
max_input_time=1600
upload_max_filesize=400M
and file_uploads is of course set to On.
I also put this line to top of my upload.php file:
set_time_limit(0);
I'm running that website on Windows Server 2008 R2 with Parallels Plesk 12.0.8.
I search this problem on Google too much but none of the solutions work on my case.
I read the same scenario in this question, which the owner of the question replied that he solved the problem by increasing client_max_body_size value in nginx.conf file, but I could not find anything about this file in Windows server so I thought it is only exists on Linux systems.
What could cause this problem?
I've solved it.
I changed PHP's debugger from FastCGI Application to CGI Application on Plesk, and that solved it.
But be careful, it caused me a couple of errors in other pages of the website, and I've fixed them all again.
Hope that helps.

File upload 404 error on server

I have a PHP file up-loader that we use to upload around 10-15 5mb images every day. I have the image uploader locally and i can upload images fine. I changed all the settings in my php.ini to ensure than i had the correct limits.
Now, i have put the up-loader on a windows server and it has the same settings, but sometimes (not always) when i upload 10-15 images it gets to 97 percent and throws a 404 document not found error.
Does anyone have any ideas as to why this could happen? I have been trying to sort this for days it is really frustrating. I'musing php 5.6 on iis.
IIS returns a 404 error when a POST length is too large:
HTTP Error 404.13 - CONTENT_LENGTH_TOO_LARGE
You'll need to increase the file upload limit using the parameter:
requestLimits.maxAllowedContentLength
Details of both of these items are on the IIS website:
https://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits
For me it turned out to be neither of the PHP or any settings for maximum filesize setting in php.ini.
The IIS on the other hand limited the post upload size.
To change go to your website in the IIS Manager
Click on Request filtering
In the right pane select Edit Feature settings
Change the Maximum allowed content length to your desired byte length which is the maximum value (we used 100MB or 104857600 bytes)

Can't upload large file in Laravel (php.ini settings are correct in my opinion)

I have the following problem in Laravel.
I would like to upload a file through a form. But for some reason if the file is larger than around 2100 KB, the validation fails, and says that the file is 'required' and I did not provide it.
I've read numerous articles, that this can be because of php.ini settings. On my server they are the following:
upload_max_filesize 64M
post_max_size 64M
These values are copied from the output of phpinfo(), so they are in effect.
And despite this, the upload fails even for a 2 MB file. Do you have any ideas what I could check/set to solve this?
I am using laravel 5.2, and PHP 7.
Check which server software you are using. Nginx for instance has it's own limit (default set to 1MB I believe). Apache might have it too. Consult the respective manuals for those packages on how to configure them. Or if you're using shared hosting, contact support to see if they can increase the limit.
Though this isn't a really scalable solution. Next time you might want to upload a 100MB file, and you probably don't want to allow 100MB requests on your servers. A better approach would be to split the file in smaller chunks in the frontend, with JavaScript, and submit them as parts of the same upload, then recombine the parts on the server once the file is completely uploaded. Beware of additional checks you'll have to do here though.
You might want to incorporate the following into your own code:
<?php
//--- this tries to override the default of only 2M file uploads.
ini_set("upload_max_filesize","25M");
ini_set("max_execution_time",600); //--- 10 minutes
ini_set("post_max_size","35M");
ini_set("file_uploads","On");
?>
In my case, it was HDD space issue. not enough space to store the file.
Laravel should handle it with proper message, instead of indicating user didn't upload anything.
If you are not using any other package to upload files to check , then
then remember to restart apache .

HTTP Error on large file upload in Wordpress

I have looked for this problem's solution everywhere but nothing seems to be working.
I get HTTP Error while uploading a file (PDF) with size around 10 MB. I also tried uploading another PDF with size 4 MB and it got uploaded at once. No issues.
Note: I have increased the default upload file size limit to 32 MB by using the custom plugin here
Please suggest me what to do. I do not have any php.ini and .htaccess. And I have no support from my hosting provider. Please help.
once check your php configuration
post_max_size & upload_max_filesize
Check upload settings
/wp-admin/settings.php
In my case the cause was plugin All In One WP Security an its "Basic Firewall Settings". The above firewall features are applied via your .htaccess file and one if these features is "Limit file upload size (10MB)."
So to make upload of files larger then 10 MB working again you can do following:
1) Go to WP Security / Firewall / Basic firewall rules tab and uncheck "Enable Basic Firewall Protection". Then Save settings. This will disable all Basic firewall settings and this 10 MB upload limitation as well.
or
2) If you want to keep the basic firewall rules but remove only that limitation, you need to use “Custom Rules”. Go to WP Security / Firewall / Custom rules tab and check "Enable Custom .htaccess Rules:". Then put in the custom rules text area:
LimitRequestBody 64000000
That will allow approx. 64 MB uploads. Also make sure that “Place custom rules at the top” checkbox is NOT checked, so it overwrites the 10M limit from above.

Wordpress Max File Upload Problem

I have created a wordpress custom post type. I am using custom field template to create fields. I have created a file field to upload images. When I upload files then It work like a charm but only 20 files get uploaded and other files get ignored. I know Its a php configuration and I have override the configuration by putting a php.ini file on my server root. Here is what I have done in it.
max_file_uploads = 300
When I run this command to check the configuration values:
echo "max_file_uploads: " . ini_get('max_file_uploads');
Then in output I get 300. But still I am unable to upload more then 20files in a single post. Am I missing something?
P.S I have a shared server and the files I am uploading have max size upto 1.5KB
Check my comment on your question above. Consider having an upload helper like fileuploader. This way, every upload is a request so no limit is reached.
Uploadify allows you to drag&drop files and select multiples files to upload (although they are sent one by one).
I had this same problem, although mine was limited to 25. The issue was the default suhosin.upload.max_uploads setting was set to 25, and like PHP versions before 5.3.4, empty upload fields would count towards this total.
The solution was to override the default suhosin.upload.max_uploads setting after it is included in php.ini. Look for the line extension="suhosin.so" and make sure it is somewhere after that.

Categories