I have a very serious issue, Laravel upload image validation not working I can still upload malicious files into the server with an extension "image.shtml".
why did validation fail to deduct it?
here is my validation code:
public function store(Request $request){
$validator = Validator::make($request->all(),[
'title' => 'required',
'image' => 'image|mimes:jpeg,png,jpg,gif',
]);
if ($validator->fails()) {
return redirect('memberproduct/create')
->withErrors($validator)
->withInput();
}
}```
checkout validation of mime types and mimes by file extension
mimetypes:text/plain,...
The file under validation must match one of the given MIME types:
'video' => 'mimetypes:video/avi,video/mpeg,video/quicktime'
To determine the MIME type of the uploaded file, the file's contents will be read and the framework will attempt to guess the MIME type, which may be different from the client provided MIME type.
mimes:foo,bar,..
The file under validation must have a MIME type corresponding to one of the listed extensions.