1

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?

UPDATE: here are the request details for successful and failing request. The image is same just scaled under 100KB in successful case and over 100KB in failing case.

Successful request:

Request URL:http://example.com/upload_photo
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate
Accept-Language:en-US,en;q=0.8,fi;q=0.6
Connection:keep-alive
Content-Length:119826
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryhVIN89yYhJPjWZoS
Cookie:step1=d18d6d9cb707914642cc3df4501565c5c361feab%2B1; step2=d18d6d9cb707914642cc3df4501565c5c361feab%2B1; step3=d18d6d9cb707914642cc3df4501565c5c361feab%2B1; laravel_session=b6cc316fdb17ada3552da4168fa23ad35bc0f171%2B4nKoS74bQHSD9HjzIytxL3Tno2sBYbOKRPfemvHY
Host:example.com
Origin:http://example.com
Referer:http://example.com/album/21095
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
X-Requested-With:XMLHttpRequest
Request Payload
------WebKitFormBoundaryhVIN89yYhJPjWZoS
Content-Disposition: form-data; name="0"; filename="1c.jpg"
Content-Type: image/jpeg


------WebKitFormBoundaryhVIN89yYhJPjWZoS--
Response Headersview source
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:42
Content-Type:text/html
Date:Wed, 24 Sep 2014 01:20:09 GMT
Keep-Alive:timeout=5, max=99
Server:Apache/2.2.22 (Ubuntu)
Vary:Accept-Encoding
X-Powered-By:PHP/5.3.10-1ubuntu3.10

Failing request:

Request URL:h_t_t_p://example.com/upload_photo
Request Method:POST
Status Code:500 Internal Server Error
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate
Accept-Language:en-US,en;q=0.8,fi;q=0.6
Connection:keep-alive
Content-Length:142451
Content-Type:multipart/form-data; boundary=----WebKitFormBoundarycv7BVPR9y5npZxAB
Cookie:step1=d18d6d9cb707914642cc3df4501565c5c361feab%2B1; step2=d18d6d9cb707914642cc3df4501565c5c361feab%2B1; step3=d18d6d9cb707914642cc3df4501565c5c361feab%2B1; laravel_session=b6cc316fdb17ada3552da4168fa23ad35bc0f171%2B4nKoS74bQHSD9HjzIytxL3Tno2sBYbOKRPfemvHY
Host:example.com
Origin:http://example.com
Referer:http://example.com/album/21095
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36
X-Requested-With:XMLHttpRequest
Request Payload
------WebKitFormBoundarycv7BVPR9y5npZxAB
Content-Disposition: form-data; name="0"; filename="1d.jpg"
Content-Type: image/jpeg


------WebKitFormBoundarycv7BVPR9y5npZxAB--
Response Headersview source
Accept-Ranges:bytes
Connection:close
Content-Encoding:gzip
Content-Length:829
Content-Type:text/html
Date:Wed, 24 Sep 2014 01:21:42 GMT
ETag:"141df4-73b-5030bebf5947d"
Last-Modified:Sun, 14 Sep 2014 19:57:01 GMT
Server:Apache/2.2.22 (Ubuntu)
Vary:Accept-Encoding
  • "I cannot find any clue in any other log file" - then your system config is broken. If you have error logging enabled in PHP then the only erason a 500 internal server would get logged is if you are running CGI/FastCGI and the PHP process aborted - in which case you would have a core dump. – symcbean Sep 23 '14 at 15:42
  • "then your system config is broken" - I would rather say that I just don't know where to look. That's why I'm asking advice here. PHP error logging is E_ALL & ~E_DEPRECATED and Server API => Command Line Interface. Any ideas where I could try to find more information what is triggering the 500 error? – Laowai Sep 23 '14 at 16:13
  • Can you check the HTTP request that is being sent to your server and show it here, both for the successful and failing upload? Use the Developer Tools in Chrome, and look under the Network tab. – Garreth McDaid Sep 23 '14 at 21:16
  • I have edited original post to include successful and failing case request headers. – Laowai Sep 24 '14 at 1:29
1

The reason was apache mod_fcgid which was limiting file upload size to 128KB by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.