Im trying to import file excel(xlsx) to database using Maatwebsite but got this error.I have function store in my baserepositore. When i add function store to ScheduleController it run and return schedule.index
but it not import my excel file. Please help me
enter code here
public function importSchedules(Request $request)
{
Excel::import(new ScheduleImport, request()->file('file')->store('files'));
return redirect()->route('schedule.index')->with('success');
}
<div class="form-group">
<form method="post" action="/schedule" enctype="multipart/form-data">
@csrf
<input type="file" name="file">
<button type="submit" class="btn btn-primary">add</button>
</form>
</div>
Route::post('/schedule', 'ScheduleController@importSchedules');
My Answer:
>file('file'));
Make sure you have the `ScheduleImport` class defined and that it is importing the data correctly from the Excel file. Also, make sure that the `store` method in your `ScheduleController` is properly defined to handle the imported data and store it in the database.
If you continue to experience issues, please provide more details or code snippets for further assistance.
Rate this post
4 of 5 based on 4100 votesComments