What exactly are you trying to achieve? Do you get any error messages?
I have faced this issue too. I have found solution from here.
http://stackoverflow.com/questions/6654351/check-file-uploaded-is-in-csv-format
here is my code snippets :
$file = $request->file('file'); $errors; if(empty($file)) { $errors[] = ' Please select file to import !!!'; } else if (!in_array($file->getMimeType(), array('application/vnd.ms-excel', 'text/csv', 'text/plain', 'text/tsv'))) { $errors[] = ' Please import only CSV file !! '; }
if(!empty($errors)) { for($i=0; $i<count($errors); $i++){ flash()->error($errors[$i]); } } else { $file_name = time(); $file->move(DIR.'/storage/', $file_name.'.csv'); flash()->success('File imported successfully !!!'); }
Hope this will help.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community