Wednesday, March 8, 2017

Laravel 5 File Uploading Error

I`m new to laravel 5.4 .while um developing the function it gives error like this.

ReflectionException in RouteSignatureParameters.php line 39: Method App\Http\Controllers\UserController::insertFile() does not exist

Here is my view called uploadfile.blade.php

    {!! Form::open(array('url' =>'insertfile','method' =>'POST', 'class' =>'form-horizontal','files'=> true)) !!}

<h2>Upload your files </h2>
<form class="form-horizontal">
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">Title</label>
    <div class="col-sm-10">
      <input type="text" name="file_title" class="form-control file_title_c" id="file_title_id" placeholder="Enter Title">
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Upload</label>
    <div class="col-sm-10">
      <input type="file" name="filenam" class="filename">
    </div>
  </div>

    <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">Submit</button>
    </div>
  </div>
{!!Form::close() !!}

Here is my developing controller UploadController

 public function index(){

        return view('upload/uploadfile');
    }

    public function insertFile(){

        $filetitle=Input::get('file_title');
        $file=Input::file('filenam');

        echo $filetitle;
        echo $file;
    }

Here is the route

Route::get('upload', 'UploadController@index');
Route::post('insertfile', array('as'=>'insertfile','uses'=>'UserController@insertFile'));



via Dasun

Advertisement