I am trying to upload CSV file in my laravel project but everythime its throwing
Whoops! There were some problems with your input.
The file failed to upload.
Can anyone tell me what could the issue. Here is my code
Route File:
Route::Get('upload','AdminVideoController@upload');
Route::Post('import-data','AdminVideoController@importData')->name('import-data');
Controller :
//File upload form
public function upload(){
return view('pages.admin.fileupload');
}
//import data
public function importData(Request $request)
{
$validator = Validator::make($request->all(), [
'file' => 'required'
]);
if ($validator->fails()) {
return redirect()
->back()
->withErrors($validator);
}
$file = $request->file('file');
$csvData = file_get_contents($file);
dd($csvData);
}
Fileupload Blade
<form class="fileupload" action="" method="POST" enctype="multipart/form-data">
<div class="row">
<div class="col-lg-6 col-md-6 col-xs-12">
<div class="form-group">
<label for="file">Select a file to upload</label>
<input type="file" name="file" id="file" class="form-group">
</div>
</div>
<div class="col-xs-12">
<button type="submit" class="btn btn-primary">Upload</button>
</div>
</div>
</form>
This might seem to be a duplicate post to a lot but i have tried those solution but no success. Can anyone please take a look at my code and let me know where is the issue?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2yBqVZf
via IFTTT
Aucun commentaire:
Enregistrer un commentaire