Support the ongoing development of Laravel.io →
posted 10 years ago
Forms
Last updated 2 years ago.
0

What exactly are you trying to achieve? Do you get any error messages?

0

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.

  • Regards
0

Sign in to participate in this thread!

Eventy

Your banner here too?

extjac extjac Joined 14 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.