raviSoni
3 months ago
467
14
Laravel

Problem in uploading a file

Posted 3 months ago by raviSoni

Hello everyone i need to upload a file in database but i got error

my view file is

<div class="modal-content">
 <div class="modal-header">
 <button type="button" class="close" data-dismiss="modal">&times;</button>
   <h4 class="modal-title">File upload form</h4>
    </div>
    <div class="modal-body">
    <!-- Form -->
    <form method="post" action="{{ route('upload.file') }}" enctype="multipart/form-data">
    {{ csrf_field() }}
    Select file : <input type='file' name='file' id='file' class='form-control' ><br>
    <input type='submit' class='btn btn-info' value='Upload' id='upload'>
    </form>
    </div>

my controller is

public function store(Request $request) { if($request->hasFile('file')) {

        $filename = $request->file->getClientOriginalName();
        $fileExtension=$request->file->getClientOriginalExtension();
        $request->file->storeAs('public/storage',$filename,$fileExtension);
        $file = new File;
        $file = save();
        return 'yes';
    }
    return $request->all();
}
public function showUploadForm()
{
    return view('vendorQuote_details');
}

my route is

Route::get('file','[email protected]')->name('upload.file');
Route::post('file','[email protected]');

Please sign in or create an account to participate in this conversation.