Laravel How to upload EXCEL file to database?
My Laravel version is 5.6.and PHP is 7.
I found some upload sample on the internet, but most of them do not work.
Have anyone can provide a complete example to me?
I found a similar case on the Internet.
Laravel 5.6 Excel and CSV import export using maatwebsite example
Unfortunately, it doesn’t work, too.
Here is my source code.
blade.php
<form class="form-upload" method="POST" action="" enctype="multipart/form-data">
<div class="form-group">
<label for="file">excel upload</label>
<input type="file" id="file" name="ex_file">
<p class="help-block">!!!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default">cancel</button>
<button type="submit" class="btn btn-primary" id="upload_f">submit</button>
controller.php
public function excelUpload(Request $request){
if($request->hasFile('StudentUploadSample')){
return "yes i have a file";
}
return "nofile";
}
However, the result always show “nofile“.
I didn’t use any “use“. Should I use something?
The example on the web page does not use any “use“, too.
In addition, I read some of the websites that the files will be placed under the storage folder, but I can’t find my file “StudentUploadSample.xlsx” in the storage folder.
Have anyone can provide a complete example to me or how to solve this problem?
from Laravel Questions and Answers https://laravelquestions.com/php/laravel-how-to-upload-excel-file-to-database/
via Lzo Media
No comments:
Post a Comment