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
First tell that this is not the proper solution. But you can try this.
I've searched also for that and having so much trouble validating excel file and their mimes type is not working for that unfortunately.
if($request->hasFile('file'))
{
$extension = File::extension($request->file->getClientOriginalName());
if ($extension == "xlsx" || $extension == "xls" || $extension == "csv") {
//'Your file is a valid xls or csv file'
}else {
//'File is a '.$extension.' file.!! Please upload a valid xls/csv file..!!');
}
}
in namspace include must use File;
You can validate any file by this way, Thanks.