F
Filamentβ€’7d ago
Benson

Cannot upload PDF

I have the following component in a form
Forms\Components\FileUpload::make('resume_file_name')
->label('')
->image()
->acceptedFileTypes(['application/pdf'])
->maxSize(5000)
->columnSpanFull()
->required(),
Forms\Components\FileUpload::make('resume_file_name')
->label('')
->image()
->acceptedFileTypes(['application/pdf'])
->maxSize(5000)
->columnSpanFull()
->required(),
it's simple. All I need is for it to accept pdf files and upload on submit. Whenever I select a pdf file, I get an error (attached). in the console it says Failed to load resource: the server responded with a status of 422 (Unprocessable Content) This only seems to happen for PDF files. I changed the component to image, and I was able to successfully upload a file. What have I tried? - published the livewire config and updated the rules and set the max_upload_time
'temporary_file_upload' => [
'disk' => null, // Example: 'local', 's3' | Default: 'default'
'rules' => ['mimes:pdf,jpg,png', 'max:12288', 'file', 'required'], // 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', 'pdf',
],
// "rules" => "file|mimes:pdf|max:49152",
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
],
'temporary_file_upload' => [
'disk' => null, // Example: 'local', 's3' | Default: 'default'
'rules' => ['mimes:pdf,jpg,png', 'max:12288', 'file', 'required'], // 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', 'pdf',
],
// "rules" => "file|mimes:pdf|max:49152",
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
],
- modified the php.ini config to include the following
upload_max_filesize=20M
post_max_size=20M
upload_max_filesize=20M
post_max_size=20M
- ChatGPT (😭) Any aassistance would be greatly appreciated.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin