1
votes

I am creating a system To upload and save all data from excel/csv sheet to Database. It work fine for small files but whenever I try to upload Large file like 250MB, 500MB files I get an error

The import file failed to upload.

I upgraded My Post Max limit in php.ini file to 1GB. Max Memory Uses, Max Execution Time. But Nothing is working.

Plugin I am using with Laravel is Maatwebsite 3.1

3
what webserver you're using?veelasky
If you get any log messages, add them to your question.Calos

3 Answers

1
votes

Try set the value of upload_max_filesize and post_max_size in your php.ini :

; Maximum allowed size for uploaded files.

upload_max_filesize = 500M

; Must be greater than or equal to upload_max_filesize

post_max_size = 500M

but it's not recommended, because it can cause server overload.

0
votes

Try to chunk or batch the import: https://laravel-excel.maatwebsite.nl/3.1/imports/chunk-reading.html

Here is an example from the documentation guide:

namespace App\Imports;

use App\User;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithChunkReading;

class UsersImport implements ToModel, WithChunkReading
{
    public function model(array $row)
    {
        return new User([
            'name' => $row[0],
        ]);
    }

    public function chunkSize(): int
    {
        return 1000;
    }
}
0
votes

Set your QUEUE_DRIVER = database in your .env file.

I always got a '504 Timed out' when uploading big excel file. But with 'QUEUE_DRIVER = database' it uploads perfect.