Upload does not validate quantity and size

Hello everybody. Guys, I have an UploadFile component configured to receive only one file and a maximum of 100Kb, but when I test it, it is not being validated. It allows more than 1 file and any size. Does anyone know what can it be?
FileUpload::make('imagens')
->label('')
->disk('public')
->directory('images/' . now()->format('Y/m/d'))
->imageEditor()
->image()
->maxFiles(1)
->maxSize(100)
->multiple()
->appendFiles()
->reorderable()
->panelLayout('grid'),
FileUpload::make('imagens')
->label('')
->disk('public')
->directory('images/' . now()->format('Y/m/d'))
->imageEditor()
->image()
->maxFiles(1)
->maxSize(100)
->multiple()
->appendFiles()
->reorderable()
->panelLayout('grid'),
No description
Solution:
It could be a bug. Feel free to submit an issue on GitHub. 🙂
Jump to solution
4 Replies
awcodes
awcodes5mo ago
Please don't tag people. File size validation doesn't get triggered until the form is submitted, so a user can upload a file that is larger, but it won't get stored permanently and the form won't save unless they change the uploaded file. The reason you are getting multiple files allowed is because you are adding these to the field:
->multiple()
->appendFiles()
->reorderable()
->panelLayout('grid')
->multiple()
->appendFiles()
->reorderable()
->panelLayout('grid')
The field is only one upload by default, so you don't need any of that if you want to only allow one file.
joao nivaldo
joao nivaldo5mo ago
I apologize for tagging Dan. I've already tried to find an answer to this in several other ways and haven't found it. I will remove the tag. Now about setting maxfiles = 1, it's just to test whether it would crash with more than one upload. But in this field there will certainly be higher values because it is a limited gallery of images. Regarding validation, it actually works after submitting the form, but I have another project with version V2.17 and there it validates everything in real time. See the attached images. That's why I have this doubt. Did the behavior change in version 3? Thanks.
No description
Solution
awcodes
awcodes5mo ago
It could be a bug. Feel free to submit an issue on GitHub. 🙂
joao nivaldo
joao nivaldo5mo ago
ok. Thanks