File upload 404 error on server - php

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)

Related

How to prevent too large files from being uploaded before upload starts even if client bypasses front end validation

On the back end I validate the file size by reading $_FILES['input_name']['size'] and returning an error message if the file size is too large. However, the back end code runs after the file has already been uploaded and this wastes the time and bandwidth of the server. I want to validate the file size before the upload begins. Existing solutions suggest that I use JavaScript to validate the file size on the front end. However, front end validation is not guaranteed and can be bypassed by users by modifying page source code. How to validate the file size on the back end and reject the request if the file size is too large without having to wait to receive the entire file first?
Edit:
Alright, since it's not possible to get the actual file size on the server side before the upload begins, let's try to think in a different way to increase server efficiency.
I want to make the post_max_size and upload_max_filesize have small values so that the server will not spend hours receiving a very large file. The problem is: The server will display a warning message (not sure if it's visible by default during production) like this:
Warning: POST Content-Length of 3071934808 bytes exceeds the limit of 41943040 bytes in Unknown on line 0
I want to show my custom error message and hide any warnings/errors displayed in the browser by the server by default during production.
Also I was wondering, let's say if the post_max_size and upload_max_filesize are both 40M but the user uploads a 10GB file. Will the server wait for the entire 10GB to be uploaded or will interrupt the request once it reaches 40MB?

What is the maximum file size allowed to send through REST API

Is there a restriction on the file size to send through the REST API?
I have a file field in a web form in my Drupal Website and sending the uploaded file to the SugarCRM application through REST API using base64_encode function.
This is working fine for the small files. But when we try to upload files around 2 MB the file, it is sending an empty value.
Is there a limit on file size that can be sent through REST API? If so, is there any other way I can send a big file(at least 2MB) to my SugarCRM application?
Google did not help me this time. If someone could, that would be great.
If you have root access on your machine, this is the most reliable and universal approach to increasing the maximum file upload. Find the php.ini file. The most common location for php.ini is /etc/php.ini. If the file is not there, you can determine where php.ini lives by using the phpinfo() function.
Once you've located php.ini, there are two settings you need to change, the max post size and max file upload size.
Maximum size of POST data that PHP will accept.
post_max_size = 2M;
Maximum allowed size for uploaded files.
upload_max_filesize = 2M;
Change these values to the maximum upload size you would like to allow. After making the changes check that the changes have been applied by checking phpinfo()
in your admin panel, you need to edit upload.php file to increase the input upload value size.
your question is not clear, if you can - provide some code's that's are creating problems or post a error logs.

Wordpress: 413 Request Entity Too Large

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;
...

Laravel + AJAX file upload fails due to file size

Uploading files larger than around 100KB fails with 500 server error. The site is built on Laravel and is using AJAX for file uploading. Small files can be loaded without problems.
I have tested uploading with the same image that is scaled with GIMP to smaller than 100KB and another one which is scaled bigger than 100KB, so the problem cannot be file type or anything related to image itself instead the problem seems to be related only to file size.
I have checked php.ini for max memory, upload_max_filesize, post_max_size and all are fine. I have also checked that apache virtualhost is not having max file size configuration. I have checked apache logs and it shows only 500 server error without anymore details. I cannot find any clue in any other log file. I have debugged the jQuery to AJAX call and ensured that the called function on PHP side is not being called. I have tried to check Laravel configurations, but couldn't find anything that could be related.
Any ideas where the file size limit could be coming from? Or any ideas where to get more information where the 500 is coming from?
The reason was apache mod_fcgid which was limiting file upload size to 128KB by default.

Increase file upload size but cannot locate/access php.ini

I'm testing a file uploading page etc that I'm working on. Chose a largish file at random and received:
Request Entity Too Large
The requested resource
/admin.php
does not allow request data with POST requests, or the amount of data provided in the request exceeds the capacity limit.
as an error message. Brief google led to changing values in php.ini but I can't locate or access it.
The site is hosted on a free site 000.webhosting.org - I'm guessing they have it restricted somehow. Is there a workaround?
Create an .htaccess document and put it in you document root directory. Inside, place:
php_value upload_max_filesize 10M
Source: http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/
Honestly, I've never tried this, but it appears to be what you need.
Edit:
Here's something else I found, you can try: ini_set("upload_max_filesize", "xM"); where x is a number and the M signifies Megabytes. I'm not sure if it works with all versions, but it's listed as being editable on the php website (http://www.php.net/manual/en/ini.list.php).

Categories