Homestead & uploading large files (L4.2)

Posted 4 years ago by theUnforgiven

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.

Please sign in or create an account to participate in this conversation.