Uploads Larger Than 16MB
I can't upload files larger than 16MB in FilamentPHP v3.
I've already checked the Apache and php.ini settings, published the Livewire configuration file with php artisan livewire:publish --config, and followed Livewire's own suggestions.
Here are the images of the files and the error.
I am asking for help because this is already in production.
24 Replies
It’s a 422 so the server is saying it cannot process the content
but smaller files it processes.
it seems to be php config. Have you set upload_max_filesize and post_max_size and reload apache ?
Check the apache error log. It seems your are on Ubuntu, log file is on /var/logs/apache/error.log
[Thu Jul 04 06:01:40.209834 2024] [php:error] [pid 968729] [client 45.175.18.112:54003] PHP Fatal error: Could not check compatibility between App\Filament\Resources\Diario\PublicacoeResource::form(Filament\Resources\Form $form): Filament\Resources\Form and Filament\Resources\Resource::form(Filament\Forms\Form $form): Filament\Forms\Form, because class Filament\Resources\Form is not available in /var/www/portalgov/app/Filament/Resources/Diario/PublicacoeResource.php on line 46, referer: https://portalgov.tec.br/admin/diario/publicacoes
[Thu Jul 04 06:03:40.857208 2024] [php:error] [pid 968664] [client 54.36.115.221:42830] PHP Fatal error: Could not check compatibility between App\Filament\Resources\Diario\PublicacoeResource::form(Filament\Resources\Form $form): Filament\Resources\Form and Filament\Resources\Resource::form(Filament\Forms\Form $form): Filament\Forms\Form, because class Filament\Resources\Form is not available in /var/www/portalgov/app/Filament/Resources/Diario/PublicacoeResource.php on line 46
[Thu Jul 04 06:03:41.653512 2024] [php:error] [pid 968663] [client 54.36.115.221:43174] PHP Fatal error: Could not check compatibility between App\Filament\Resources\Diario\PublicacoeResource::form(Filament\Resources\Form $form): Filament\Resources\Form and Filament\Resources\Resource::form(Filament\Forms\Form $form): Filament\Forms\Form, because class Filament\Resources\Form is not available in /var/www/portalgov/app/Filament/Resources/Diario/PublicacoeResource.php on line 46
[Thu Jul 04 06:16:36.472038 2024] [mpm_prefork:notice] [pid 968657] AH00170: caught SIGWINCH, shutting down gracefully
[Thu Jul 04 06:16:36.679211 2024] [mpm_prefork:notice] [pid 969863] AH00163: Apache/2.4.58 (Ubuntu) OpenSSL/3.0.13 configured -- resuming normal operations
[Thu Jul 04 06:16:36.679339 2024] [core:notice] [pid 969863] AH00094: Command line: '/usr/sbin/apache2'
upload_max_filesize is 1024M
and what is post_max_size php config ?
To increase the simultaneous upload limit.
yes post_max_size need to be equal or higher than upload_max_filesize.
it's the same 1024M
Do you use php-fpm (see if good php.ini is modified) ? Have you configured a proxy (with proxy_pass for example) ? Could you share your apache host config ?
No other ideas 😄
<VirtualHost *:80>
ServerName portalgov.tec.br
ServerAlias www.portalgov.tec.br
ServerAdmin [email protected]
DocumentRoot /var/www/portalgov/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.portalgov.tec.br [OR]
RewriteCond %{SERVER_NAME} =portalgov.tec.br
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
<Directory /var/www/portalgov/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
php_value upload_max_filesize 1024M
php_value post_max_size 1024M
php_value max_execution_time 300
php_value max_input_time 300
LimitRequestBody 209715200
</Directory>
Timeout 300
</VirtualHost>
would it be this?
I don't use php-fdm
Is this a local stack?
I need to follow the request and see where it's blocked (whether the log is in access.log with a 422 error code or in error.log, ...). It's very strange. I can't debug it without being on the server.
is in production
45.175.18.112 - - [04/Jul/2024:08:22:10 +0000] "GET /admin/diario/publicacoes HTTP/1.1" 200 29479 "https://portalgov.tec.br/admin/relatorio-fatura-page" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
45.175.18.112 - - [04/Jul/2024:08:22:15 +0000] "GET /admin/diario/publicacoes/create HTTP/1.1" 200 27478 "https://portalgov.tec.br/admin/diario/publicacoes" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
45.175.18.112 - - [04/Jul/2024:08:22:18 +0000] "POST /livewire/update HTTP/1.1" 200 2850 "https://portalgov.tec.br/admin/diario/publicacoes/create" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
45.175.18.112 - - [04/Jul/2024:08:22:26 +0000] "POST /livewire/update HTTP/1.1" 200 5702 "https://portalgov.tec.br/admin/diario/publicacoes/create" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
45.175.18.112 - - [04/Jul/2024:08:22:26 +0000] "POST /livewire/upload-file?expires=1720081646&signature=5449ae0fa3cd121773ae40008f6fd5cdc1db6c6b0e26f8026fad0e05060ca3d7 HTTP/1.1" 422 1344 "https://portalgov.tec.br/admin/diario/publicacoes/create" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
45.175.18.112 - - [04/Jul/2024:08:22:30 +0000] "POST /livewire/update HTTP/1.1" 200 77787 "https://portalgov.tec.br/admin/diario/publicacoes/create" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
it looks like this in access.log
In my opinion, it seems it's not an Apache/PHP issue; otherwise, you would get an error in the errors.log file.
How is your FileUpload component configured in form ? Have you set a maxSize ?
The error appears after how much time (upload) ?
The problem was only noticed when it went into production.
Here's the form.
Forms\Components\FileUpload::make('diario_jornal')
->label('Jornal')
->maxSize(1024)
->imageEditorAspectRatios([
null,
'16:9',
'4:3',
'1:1',
])
->maxSize(1048576)
->preserveFilenames()
->downloadable()
->openable()
->directory('uploads')
->live(onBlur: true)
->disabled(function ($livewire){
$existe = $livewire->getRecord();
if(empty($existe->fechado))
{
return false;
}else{
if($existe->status_id === 1)
{
return false; } else{ return true; } } } ) ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file, $record): string => (string) str($record->name) . '.' . $file->getClientOriginalExtension(), ) ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file): string => (string) str(now()->timestamp).'-Jornal'. '.' . $file->getClientOriginalExtension() ), I created a file for uploading in PHP and uploaded large files without any problems. This rules out the problem being in php or apache.
return false; } else{ return true; } } } ) ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file, $record): string => (string) str($record->name) . '.' . $file->getClientOriginalExtension(), ) ->getUploadedFileNameForStorageUsing( fn (TemporaryUploadedFile $file): string => (string) str(now()->timestamp).'-Jornal'. '.' . $file->getClientOriginalExtension() ), I created a file for uploading in PHP and uploaded large files without any problems. This rules out the problem being in php or apache.
You have two maxSize on your file upload. I think the last is taken but not sure 😅
I glued the wrong one, but the others only have one and it still doesn't work.
Forms\Components\TextInput::make('diario_jornal')
->label('Jornal')
->required()
->extraInputAttributes(['type' => 'file']),
Just try to increase the php memory_limit attribute before excluding it
I went up to 2048M, but it still doesn't go up.
with the previous change it wasn't either.
What is the error shown in your form view ?
"error during sending", and in the conslole: Failed to load resource: the server responded with a status of 422 (Unprocessable Content)
In apache, maybe there is multiple config files for port 80 and 443 and the wrong config You edit. Maybe also for location /livewire is multiple entrys..