Problem: if the downloaded file exceeds 5000 kb, the validator returns the message "required" instead of the message "max". Why?
$file = (Input::file('inputName')); $fileValidator = Validator::make( array('Field Name' => $file), array('Field Name' => 'required|max:5000|mimes:jpeg,png,bmp') ); if($fileValidator->fails()){ return $fileValidator->errors()->all(':message'); }
Update: This issue is especially important for checking * .psd files.
Update 2: when I var_dump ($ file), I see this:
object(Symfony\Component\HttpFoundation\File\UploadedFile)#9 (7) { ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false) ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(52) "4-47970_rsasecurityanalyticsevolutionofsiemebook.pdf" ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(24) "application/octet-stream" ["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0) ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(1) ["pathName":"SplFileInfo":private]=> string(0) "" ["fileName":"SplFileInfo":private]=> string(0) "" }
As you can see, the path name and file_name look null. So why laravel returns the requested message. Here's a new question: why is file_name null?
source share