Level 9
You need to specify that you're uploading files to your form.
'files' = true if you're using the Form:: handling facade or enctype="multipart/form-data" otherwise.
I'm trying to upload a file and add the contents to my database using Laravel Excel. The file is uploaded using a form which posts to my uploadFromCsv method.
When I upload the file I get:
PHPExcel_Reader_Exception in Excel2007.php line 82: Could not open for reading! File does not exist.
My form is:
<form class="form-horizontal" method="POST" action="/ascents/upload">
{!! csrf_field() !!}
<div class="form-group">
<label for="file" class="col-sm-3 control-label">Select CSV File</label>
<div class="col-sm-9">
<input type="file" class="form-control" id="file" name="file">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-default">Upload</button>
</div>
</div>
</form>
And my method is:
public function uploadFromCsv()
{
Excel::load(Input::file('file'), function ($reader) {
foreach ($reader as $log) {
$ascent = new Ascent($log->all());
Auth::user()->ascents()->save($ascent);
}
});
return redirect(route('ascents'));
}
You need to specify that you're uploading files to your form.
'files' = true if you're using the Form:: handling facade or enctype="multipart/form-data" otherwise.
Please or to participate in this conversation.