Are you sure the txt file is a really a txt file? Laravel is not checking your file when validating. It's only checking the mimetype of the file. You can change the extension of a file, but that might nog change the original mimetype of the file and therefore it's not a txt file!
MIME detecting as not TXT, but it's TXT - Email Info Inside
I'm using Laravel validation for an uploaded file. The validation string looks something like this:
'file_upload' => 'required|file|max:50000|mimes:zip,csv,doc,docx,gif,jpe,jpeg,jpg,json,log,pdf,png,ppt,pptx,saz,txt,xls,xlsx,xml',
When I upload almost any text file, this works great.
However, when my text file contains information you might ordinarily find in a text file that was copied / pasted or exported from an email message, the validation fails, I assume because the validator is peeking inside the text file to see that stuff.
Example of the content:
From: Jane Smith <[email protected]>
Sent: Friday, July 13, 2018 8:25 AM
To: John Smith
Cc: Alfred Smith, Zach Smith
Subject: RE: You really have to see this awesome chain letter!
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec venenatis sem sit amet lorem cursus tempor. Cras dolor risus, efficitur quis justo posuere, tempus malesuada odio. Nullam cursus odio et orci molestie, at elementum ante sollicitudin. Curabitur sagittis dignissim nisi, ut tincidunt leo maximus non. Duis auctor est nisi, ut porta erat aliquet ut. Proin porttitor volutpat ante. Sed ornare turpis volutpat ex commodo elementum. Donec interdum, urna vitae faucibus ultrices, magna massa iaculis lorem, eu venenatis nisl arcu nec justo. Sed malesuada eros neque, eget mollis sem fermentum a. Donec porttitor tincidunt ligula, vitae tincidunt eros facilisis quis.
So when my text file contains those first 5 lines, validation fails. When my text file does not contain those first 5 lines, validation passes.
I do not want to include .msg into the MIME list because I don't want to upload .msg files. However, text files that really are just plain old text files even if they're exported from an email system are fine.
Please tell me I don't have to write a custom validator for this. There has to be a bettery way?
Thank you,
Please or to participate in this conversation.