In my controller I want to set a maximum filesize and some allowed mime types a user can upload. I tried the max and size rule, none of them seems to work, I can set them to "1" and I can still upload files. The MIME types seems to be ignored. For example I can still try to upload the git setup (29MB and a .exe file)!
controller:
public function postTicket(Request $request)
{
$validator = Validator::make($request->all(), [
'departments' => 'exists:departments,id',
'attachment' =>'min:1|max:1000|mimes:txt,text,log',
]);
if ($validator->fails())
return back()->withErrors($validator)->withInput();
if ($request->hasFile('attachment'))
{
if ($request->file('attachment')->isValid())
{
$request->file('attachment')->move('../storage/app/uploads', 'lala.txt');
dd("uploaded");
}
dd("upload failed");
}
dd("no file");
}
Where's my fault I mean the validator rule doesn't check the git setup for example, with it's 29MB it should fail the size check and the MIME type exe isn't allowed too. It passes the check and all I see is:
Warning: POST Content-Length of 30617046 bytes exceeds the limit of 4194304 bytes in Unknown on line 0
"no file"
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire