must be a file of type:application/pdf

Hey guys, i have this code in my form:
Forms\Components\FileUpload::make('anyfiles')
->label('Ingrese Documentos de respaldo')
->multiple()
->acceptedFileTypes(['application/pdf'])
->directory($tenantFolder->name.'/expense/pdf')
->maxFiles(3),
Forms\Components\FileUpload::make('anyfiles')
->label('Ingrese Documentos de respaldo')
->multiple()
->acceptedFileTypes(['application/pdf'])
->directory($tenantFolder->name.'/expense/pdf')
->maxFiles(3),
i upload a pdf file but int the front return me an error "Documentos de respaldo field must be a file of type: application/pdf." any idea about this error?
No description
10 Replies
TranceCode
TranceCodeOP7mo ago
Does anyone know anything about it, I can't understand why this problem exists, it doesn't really make much sense.
Dennis Koch
Dennis Koch7mo ago
Check the actual mime type of the file. Some apps might create files with a different mime type
TranceCode
TranceCodeOP7mo ago
thank for your answer bro... The file in tmp folder is .bin, i don't know why!
No description
TranceCode
TranceCodeOP7mo ago
here i only upload the file, when i save i received the error
Dennis Koch
Dennis Koch7mo ago
Hm. I think I have seen others claiming that FilePond converts files/uploads files with the wrong extension If you check the mime type before uploading what's the result?
TranceCode
TranceCodeOP7mo ago
wel i update my code and add this line
->rules([
'mimes:pdf',
'max:10000'
])
->rules([
'mimes:pdf',
'max:10000'
])
and it working, how ever if i add this line
->acceptedFileTypes(['application/pdf'])
->acceptedFileTypes(['application/pdf'])
from the documentation, return me the error https://filamentphp.com/docs/3.x/forms/fields/file-upload#file-type-validation
Dennis Koch
Dennis Koch7mo ago
The first one are the Laravel rules which work on the backend. And I guess pdf is broader checking then application/pdf. The other rule should be used by Filepond on the frontend.
TranceCode
TranceCodeOP7mo ago
Filepond? is not the same like Fileupload?
Dennis Koch
Dennis Koch7mo ago
FileUpload uses FilePond under the hood
TranceCode
TranceCodeOP7mo ago
Ok, bro, thank you so much for the answer and explanation
Want results from more Discord servers?
Add your server