File upload for large files
I have tried all possible ways to upload large files using filament. This works on my local machine but once i deployed to server, large files are not able to upload. This is how my form schema looks like:
FileUpload::make('file')
->label('Upload Merchant pay file here')
->rules(['required', 'file', 'max:122880'])
->maxSize(122880)
->acceptedFileTypes(['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/xlsx'])
->helperText('Only .xlsx files are allowed')
->required(),
made these changes in my php.ini file:
post_max_size = 120M,
upload_max_filesize = 120M
added this to my nginx config file: client_max_body_size = 200M
funny thing is that it was not working on my local before and then added this line: ->rules(['required', 'file', 'max:122880']) which got it to work for large files. I figured it should work once i deploy on my server but issue remained the same.
i'm still not able to successfully upload.
what else do i do? nothing shows in my laravel log, nginx log and php-fpm log. any suggestions?
27 Replies
there is also livewire max size 😃
You have to update your livewire config file.
just publish its config and edit it
lol forgot to mention I already explored that option as well. But it still doesn't work
'temporary_file_upload' => [
'disk' => null, // Example: 'local', 's3' | Default: 'default'
'rules' => ['required', 'file', 'max:122880'], // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => null, // Example: 'tmp' | Default: 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs...
'png',
'gif',
'bmp',
'svg',
'wav',
'mp4',
'mov',
'avi',
'wmv',
'mp3',
'm4a',
'jpg',
'jpeg',
'mpga',
'webp',
'wma',
'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
],
'upload_max_file_size' => 122880, // 120 MB
'chunk_size' => 8192, // 8 MB per chunk
'max_file_uploads' => 10, // Allow multiple uploads if needed
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
],
refresh you config and caches
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan route:clear
php artisan route:cache
php artisan view:clear
php artisan optimize:clear
php artisan optimize
done these but still error
php artisan config:clear
php artisan config:cache
php artisan route:clear
php artisan route:cache
php artisan view:clear
php artisan optimize:clear
php artisan optimize
done these but still error
well, there is only limitationa on Livewire, PHP, Server (ngnix/appache). I don't know other possible issues. is this on local or production
local works fine. this is on production
Ah, so I think the serever config override is not accepted by the hosting provider, can you test it somehow?
they may force other limitations to lower their costs
I'm using digital ocean ubuntu server
what about the software server, is it ngnix or appache
nginx
try this in the terminal:
nginx -T | grep client_max_body_size
not expert so it maybe another nameyeahh first had that issue then placed it in my nginx http block which took away that error
client_max_body_size 128M;
#client_max_body_size 120M;
#client_max_body_size 120M;
#client_max_body_size 120M;
So is it fixed now?
the error no longer pops up in the log but its livewire upload that still throws error
try to log the config to the frontend:
public $uploadLimit;
public function mount()
{
$this->uploadLimit = config('livewire.file_upload.max_size') / 1024; // Convert to MB
}
then:
<p>Maximum upload size: {{ $uploadLimit }} MB</p>
or a js log to check the config used value
okay sure let me do that now
mmm, I think it is something with the server config as it is working in the local. no idea, sorry.
maybe search about similar issues with DO servers from the same service you use
i get 0MB both on local and production
yeahh i should probably try it on a different host. i'd research about that.
thanks a lot for the suggestion 😃
guess what the issue was all along? 😭 @Mohamed Ayaou
was modifying the wrong php ini file
did you check APP_URL?
modified it before i even began testing. issue had to do with the wrong php ini file. sigh!
I have this issue too. I'll try your fix and see if it works.
sure. let me know if you encounter any issues @eskay_amadeus
Okay so what line of the ini file did you modify and what did you set it to? I see you're from 🇬🇭 @owulanii
Check the first message:
made these changes in my php.ini file: