jeudi 2 juin 2016

Laravel 5.1 Upload file to using for PHPExcel

I want to create page upload excel file (.csv, .xls, .xlsx), after that use PHPExcel to show content excel file.

Form

<form role="form"method="post" action="">    
<div class="form-group">
    <label>Chose File .xlsx</label>
    <input type="file" id="file" name="file">
</div>
<div class="form-group">
    <button type="submit" class="btn btn-primary">Imports</button>
</div>
<input type="hidden" name="_token" value="">

Route

Route::post('upload', ['uses'=>'MainController@uploadFile']);

MainController

public function uploadFile(){
    Excel::load(Input::get('file'), function($reader) {
        $results = $reader->get();
        return Response::json($results);
    });
}

When i upload some file (Ex: test.xls), i see a error like this:

Could not open E:\wamp\www\[project-name]\test.xls for reading! File does not exist.

Somebody help me, please!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire