Laravel + AJAX file upload fails due to file size - php

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.

Related

How can increase the file upload size in Moodle when I upload the Course file?

I am uploading a zip file there but it says Error connecting to the server and I have changed the php.ini memory_limit = 9024m
There are a few places that might cause this upload issue.
I would suggest looking at your PHP.ini file to make sure that the setting there is correct.
Check the apache side as well.
With regards to increasing moodle upload sizes here is the doc: Moodle Doc
Edit 1: Error connecting to server is the default Moodle error it prints when your upload file is either too big or takes too long to upload, thus your connection times out.

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)

Upload Size PHP

I am developing a web application which will allow the administrator to upload a file and its max size is 500M.
I have changed the post_max_size = 500M and upload_max_filesize = 500M from 32M but the funny thing is that it does not allow me to upload files greater than 32M still.
I have restarted the server and everything and still cant get to upload a large file.
Is there any other setting i should change to allow me to upload the file?
I am not going to process the file in memory but move it to the tmp folder and than process from there with move_uploaded_file so memory_limit i am assuming that is not going to be affected.
It is a simple form and as i recall if the limit is exceeded in the $_FILES superglobal array i should see something in the error element of the array but instead i get an empty array.
EDIT: I am modifying the php.ini settings but from phpinfo i am still getting the sizes of 32MB. And the php error log says that obviously i am exceeding 32MB
Can you please help me out.
Thanks
Chech phpinfo() on a web page, see which php.ini is loaded. You could be editing the wrong file.
Sometimes different ini files get loaded for command line and apache server use
I fount out what the problem is:
I am using MAMP as a developing server and MAMP has templates which override the original every time the server starts (a stupid thing IMO) so you need to change the template for it to take effect!
The template can be found under /Applications/Mamp Pro/Contents/Resources
And there many php ini files for every version will be found.
Hope this helps to the next one!

Php upload strange behavior

I was testing a little application I've made and I saw a strange behaviour when uploading multiple files that exceed some size.
I've read the bug mentioned here, but its way long ago. Strangely, I experience the same behaviour as the guy mentions in the bug.
When I upload, say 10 files in small size (50-300kb each) there is nothing wrong and the application works.
When I upload, two files with 1.5mb each, the application outputs an error message as the maximum allowed size is 512kb by the application (2mb in php.ini).
When I upload, multiple files that exceed 7 or 8 mb (I haven't tried to locate the exact size), php crashes without giving an error. Since I am in a development server, the errors are turned on and normally it displays the fatal errors.
When I upload, 1 file (say 25mbs), I still have the same error.
Well, I say it crashes because when I try to var_dump($_FILES) or even var_dump($_POST) the array returns null although it should have at least the submit name or whatever.
I've checked the tmp folder and the files are not being stored there as well. However, another strange behavior is that when I upload the files that exceed this mysterious limit, the browser seems to be uploading (I see the page takes a while to load), however, as mentioned, php acts like it does not know anything.
What could be the reasong of this strange behaviour?
PS: I'm working on my localhost (wampserver) on Windows 7 64-bit.
EDIT
Found the solution:
changing post_max_size from 8mb to something else solved my problem.
Here is a quote from the manual for those who need:
Sets max size of post data allowed. This setting also affects file
upload. To upload large files, this value must be larger than
upload_max_filesize. If memory limit is enabled by your configure
script, memory_limit also affects file uploading. Generally speaking,
memory_limit should be larger than post_max_size. When an integer is
used, the value is measured in bytes. Shorthand notation, as described
in this FAQ, may also be used. If the size of post data is greater
than post_max_size, the $_POST and $_FILES superglobals are empty.
This can be tracked in various ways, e.g. by passing the $_GET
variable to the script processing the data, i.e. , and then checking if
$_GET['processed'] is set.
That is error because you have very less upload limit - upload_max_filesize or post_max_size .
in php.ini just increase value of both to 200MB and you will nt receive this error
in the server there is a limit to send post. your should be 512kb. you can check in phpinfo();
i think its the parameter in php.ini upload_max_filesize. change to bigger size.

Ajaxplorer - HTTP Error 404

I have a problem with the Ajaxplorer. I have configured it for uploading and downloading files and this is also working very well but just when the files are smaller than 100M. When I am trying to upload a bigger file there appears a I/O Error with an HTTP Error 404 (The upload is shown as completed but than the error appears).
Here is the configuration background:
PHP is running on a Windows Server 2008 R2
The max. uploading memory size is 2G (configured in the php.ini. This value is also shown in the
Ajaxplorer)
All relevant folder are writeable (i have configured the php session file and also in the
Ajaxplorer the temp file and after every uploading error i find in these directory a temporary
file so i think it´s writable)
Have you set your post_max_size as well?
--- php.net---
Sets max size of post data allowed. This setting also affects file upload.
To upload large files, this value must be larger than upload_max_filesize.
If memory limit is enabled by your configure script, memory_limit also
affects file uploading.
More info:
http://www.php.net/manual/en/ini.core.php#ini.post-max-size

Categories