I intend to insert image link like that "annonces\ August2020 \ image.jpg" into the db and image in storage but it gives me error Undefined variable: insert.
FileController.php
public function save(Request $request)
    {
       request()->validate(['file'  => 'required|mimes:doc,docx,pdf,txt,jpeg,jpg|max:2048',]);
       if ($files = $request->file('fileUpload')) {
           $destinationPath = 'public/file/'; // upload path
           $profilefile = date('YmdHis') . "." . $files->getClientOriginalExtension();
           $files->move($destinationPath, $profilefile);
           $insert['file'] = "$profilefile";
        }
        $check = Document::insertGetId($insert);
        return Redirect::to("file")
        ->withSuccess('Great! file has been successfully uploaded.');
    }
file.balde.php
<form action="/save" method="post" enctype="multipart/form-data">
                @csrf
                <div class="form-group">
                    <input type="file" class="form-control-file" name="file" id="file" aria-describedby="fileHelp">
                    <small id="fileHelp" class="form-text text-muted">Please upload a valid image file. Size of image should not be more than 2MB.</small>
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
            </form>
web.php
Route::get('file', 'fileController@index');
Route::post('save', 'fileController@save');
 
     
     
    