Ryuzakiss's avatar

Validation - TXT file is not allowed sometimes ?

Hello,

Is it possible for Laravel App to ignore a specific file txt and allowed another file txt ? I build an app where I can store some file(test) and the upload does work just fine with validation working(sometimes). When I try to upload this file: File_dataAndEveryThingUseless.txt the validation fails Error: The upload must be a file of type: csv, doc, docx, log, pdf, ppt, pptx, rtf, txt, xls, xlsx, xml. But when i upload this file: EpicTest.txt, it passes...

Here the validation code:

$validation = request()->validate([  
  'category' => ['required', 'numeric'],  
  'upload' => ['required', 'file', 'max:5120', 'mimes:csv,doc,docx,log,pdf,ppt,pptx,rtf,txt,xls,xlsx,xml'],  
]);

And also, why other file like registry.reg passes too ? Do you have to use mimeType validation ? Any thoughts ?

0 likes
2 replies
Ryuzakiss's avatar

Thanks for the link.

Indeed it's cheking the mime not extenson and the file has some html code. Probably the reason why it's not uploading.

Please or to participate in this conversation.