I am making simple file upload page.
My html code -
<form action="{{ $work_id }}/upload/" method="get" enctype="multipart/form-data">
@csrf
<div class="row">
<div class="col-10">
<input type="file" class="custom-file-input" id="customFile" name="upload_file">
<label class="custom-file-label" for="customFile">Faýly saýlaň</label>
</div>
<div class="col-2">
<input class="btn btn-outline-primary" type="submit" name="upload_file_submit" id="upload_file_submit" value="Ýüklemek">
</div>
</div>
</form>
My code in controller -
function uploadWorkFile(Request $request, $login, $work_id){
$teacher_id_result = DB::select('select `id` from teacher where login = ?', [$login]);
$teacher_id = $teacher_id_result[0]->id;
$path = $request->file('upload_file')->storeAs('teacher_works/'.$teacher_id.'/'.$work_id.'/', $request->input('upload_file'));
return $path;
}
My code in web.php
Route::get('/teacher/{login}/work_list/{work_id}/upload', 'TeacherController@uploadWorkFile');
I don't understand what happens there, please help, thanks.
encryptedattribute inside your form tag, example in<form action="/your_route" method="post" enctype="multipart/form-data">array:3 [▼ "_token" => "hLUJbuE4Mi8Wnk8ouIXfGxbGRDkXgt4dPZy6IBx9" "upload_file" => "screen.png" "upload_file_submit" => "Ýüklemek" ]