Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theUnforgiven's avatar

Homestead & uploading large files (L4.2)

I figured that seen as my other post was 'answered' then I would ask again.

Using Homestead and Laravel of course, I'm wanting to upload a CSV file more than 8MB in size, this doesn't happen. If i upload something smaller like 500KB or 1MB a PDF, Word Doc etc it works, but this 8MB+ CSV file doesn't.

I spoke to Taylor about this and he said I would need to change some settings in the php.ini file which I have done, still to no avail, so reaching out to the likes of @JeffreyWay and @bashy to give help/advice on this.

Here's both my form and controller method to do the upload.

Form:

{{ Form::open(['route' => 'books.upload', 'class' => 'form-horizontal', 'files' => true]) }}

        <p>Upload CSV file</p>
        {{ Form::file('file') }}

        <button class="btn btn-success">Upload</button>

    {{ Form::close() }}

Controller:

 // CSV File upload of Books
    public function upload()
    {

        if (Input::hasFile('file')) {

            $file = Input::file('file');
            $name = time() . '-' . $file->getClientOriginalName();
            $moved = $file->move(public_path() . '/uploads/csv', $name);



            $csv = new Reader($moved);
            $csv->setOffset(0);
            $nbInsert = $csv->each(function ($row) use (&$sth) {
                DB::table('books')->insert(

                    array(
                        'ref' => (isset($row[0]) ? $row[0] : ''),
                        'date' => (isset($row[1]) ? $row[1] : ''),
                        'sold' => (isset($row[2]) ? $row[2] : ''),
                        'author' => (isset($row[3]) ? $row[3] : ''),
                        'title' => (isset($row[4]) ? $row[4] : ''),
                        'place_date' => (isset($row[5]) ? $row[5] : ''),
                        'description' => (isset($row[6]) ? $row[6] : ''),
                        'price' => (isset($row[7]) ? $row[7] : ''),
                        'keywords' => (isset($row[8]) ? $row[8] : ''),
                        'classification' => (isset($row[9]) ? $row[9] : ''),
                        'cost' => (isset($row[10]) ? $row[10] : ''),
                        'notes' => (isset($row[11]) ? $row[11] : ''),
                        'isbn' => (isset($row[12]) ? $row[12] : ''),
                        'publisher' => (isset($row[13]) ? $row[13] : ''),
                        'pub_date' => (isset($row[14]) ? $row[14] : ''),
                        'binding' => (isset($row[15]) ? $row[15] : ''),
                        'condition' => (isset($row[16]) ? $row[16] : '')
                    )
                );
                return true;
        });
        }

        return Redirect::to('admin/books')->with('flash_success', 'Upload completed &amp; new data inserted.');
    }

Help/advice greatly appreciated.

0 likes
17 replies
bashy's avatar

I would like to help but, 1. I don't use Homestead and 2. I'd probably have to check all your PHP and Nginx settings to make sure it allowed for larger files. Could be a number of things.

theUnforgiven's avatar

I know, Taylor give me some pointers and i made the changes but still nothing. It's very annoying not been able to upload large files.

henrique's avatar

Did you also change the nginx config? Did you restart both php5-fpm and nginx after changing the configs? Does it throws/logs any error (Laravel, nginx or php)? Can you post your configs (php and nginx) so it's easier for us to help? :)

bashy's avatar

In nginx.conf, try sendfile off and make sure client_max_body_size xxxM; is set high enough, then restart nginx (not just reload)

theUnforgiven's avatar

I edited /etc/php5/fpm/php.ini then did sudo service php5-fpm restart as per instructions from Taylor on this.

bashy's avatar
bashy
Best Answer
Level 65

That was for Nginx, nothing to do with PHP.

This is my PHP setup on one of my servers, this alows 100MB files uploaded.

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 100M

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 125M

Set post_max_size higher than upload_max_size. Sure I read somewhere it should be equal or higher than upload_max_filesize. Yours is 0, looking at the other thread.

2 likes
theUnforgiven's avatar

I set these settings same as yours and did sudo service php5-fpm restart afterwards so just trying the upload now.

theUnforgiven's avatar

I get:

string 'POST: 125M' (length=10)

string 'UPLOAD: 100M' (length=12)

on that test URL i did.

PunRiffer's avatar

I have this file size issue and through it realized that I don't understand part of my setup. I'm using laravel homestead to run my project, but I don't have php5-fpm or nginx in my /etc/ folder. My Nginx conf is located in /MAMP/conf/nginx.conf. Am I missing an installation? Should I be editing config files in different locations? I'd much appreciate if someone can help me understand how the homestead environment works. (To allow me to understand and eventually learn to setup my settings so that I can upload large files).

jamilalaydrus's avatar

where i can write it syntax? i wanto upload file with 100 mb size

gobi's avatar

how to upload large file without changing default size?

Please or to participate in this conversation.