1
votes

When I try to upload files using jQuery File Upload, everything works as planned for any number of files up until 5. When I try to POST 5 or more files the server responds with a 404 Not Found, but POSTing 4 files to the same URL it upload and processes perfectly fine. What could be the issue?

I'm running nginx, php-fpm, and laravel. I even set client_max_body_size to 0 after trying high limits.

Access Log for 4 Files:

192.168.1.144 - - [14/Jan/2014:10:49:28 -0500] "POST /admin/job/1 HTTP/1.1" 302 449 "http://192.168.1.100:8080/admin/job/1/edit" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "-"

Access Log for 5 Files:

192.168.1.144 - - [14/Jan/2014:10:45:01 -0500] "POST /admin/job/1 HTTP/1.1" 404 223 "http://192.168.1.100:8080/admin/job/1/edit" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "-"

Attached are images of the console in chrome.

5 Image Upload Test

5 Images Upload Test

4 Image Upload Test

4 Images Upload Test

Edit: Code for POST Route :

public function update($id)
    {
        $input = \Input::except('photos');
        $job = \Job::findOrFail($id);
        $job->fill($input);

        if(Input::hasFile('photos'))
        {
            $photos = Input::file('photos');

            /**
             *@var $photos Uploadedfile[]
             */
            foreach ($photos as $index => $photo)
            {
                $fileName = \Str::random(8)  .'.'. $photo->getClientOriginalExtension();
                $file = $photo->move(public_path() .'/job_images/', $fileName);

                $jp = new \Job\Photo(array('image' => $fileName, 'description' => $input['description'][$index]));
                $job->photos()->save($jp);
            }
        }

        $job->save();
        return Redirect::route('admin.job.show', $id);
    }
1
Can you post the code where the route is redirecting to? - Pat
@Pat uploaded, sorry about that - William
I would suggest using die and dump before the if, before the foreach, and before the return to see where exactly its getting to but failing. - Pat
@Pat already tried that, issue being it never reaches the code. Server responds with an 404 - William
So its not even getting to the function? - Pat

1 Answers

0
votes

So after digging a little deeper I found that the error was showing up in php-fpm error log with the following messages

[14-Jan-2014 16:33:07 UTC] PHP Warning:  POST Content-Length of 9142976 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
[14-Jan-2014 16:38:45 UTC] PHP Warning:  POST Content-Length of 12260767 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

Which led me to the problem being with php, I initially changed post_max_size to 0 but needed to raise upload_max_filesize = 2M to a higher limit as well and this fixed my issue.

I also raised the limit in nginx configuration client_max_body_size to 50M;