I learned it is required to modify the values in php.ini
in order to set the limitation for uploading files. However, I'm in a situation where I can't touch php.ini
.
Let me explain the problem briefly.
<input type="file" name="thumbnail" accept="image/*">
I'm trying to get the thumbnail
and get it in a controller.
if($this->request->hasFile('thumbnail')){
$file = $this->request->file('thumbnail');
//Other tasks
}
If the file size is over a certain point, I'd like to prevent it and show a warning. However, apparently, if the uploaded file is over the limit, request->hasFile()
returns false even though it's actually true. (I saw that by dd()
)
It's probably impossible to catch this type of error by hasFile()
, since it simply doesn't catch it.
Any advice would be appreciated.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire