lundi 14 mars 2016

Fatal error in Excel2007 laravel 5

I am stuck with an error "FatalErrorException in Excel2007.php line 94: Class 'ZipArchive' not found". This happens when i uplaod an excel file,.csv file etc...

my controller function

public function store(Request $request)
        {
            $error     = '';
            $rules     = ['file' => 'required|mimes:csv,doc,docx,xls,xlsx,ppt,pptx,txt' ];
            $file      = $request->file('file');
            $validator = Validator::make($request->all(),$rules);
            if( $validator->fails() )
            {
                return redirect()->route('createcardno')->withErrors($validator)->withInput();
            }
            else{
                if( $error =="")
                {


                Excel::load(Input::file('file'), function ($reader) {

                    foreach ($reader->toArray() as $row) {
                        foreach($row as $personal){
                            $card_number            = $personal['card_number'];
                             $model                 = new UserManagement; 
                             $model->cardno         = $card_number;

                             $model->save();
                        }
                    }
                });
            }
            return redirect()->route('card');
        }
    }

Please help me to get through this.... Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire