I have an input field who allaow peoples to upload files. I want that they can upload, word files like doc, and files like csv,xlsx.
When i try with a .doc no proble
That is it! I tried it myself and if you only test for mimes:csv
it will fail when the filename has an space.
What I did to pass validation was to use required|mimes:csv,txt
.
But as you already suggested you would need to do some manual validation.
Front-end validation is a good thing regarding the user experience, but you can never trust solely in a validation that ran in a machine different than your server. If you are going to do any javascript validation, always validate it again in the server.
In your case, as it is an exception regarding an unusual filename, not an wrong format, I would relax the mime-type validation using mimes:csv,txt and then use a package to parse the CSV file, generally this packages raises an exception when the format is not valid.
Two great packages for dealing with CSV are:
[ https://github.com/Maatwebsite/Laravel-Excel ] [ http://csv.thephpleague.com/ ] Hope it helps.
[ https://laracasts.com/discuss/channels/general-discussion/csv-file-upload-request-validation ]