Missing argument 1 for stockTransferController::getfile()

211 views Asked by At

hi all i want to do upload and download files.am uploading files successfully but when i want to download file i am getting error like

Missing argument 1 for stockTransferController::getfile()

below is my code

Routes

    Route::get('stock/file','stockTransferController@getfile');

Controller

 public function uploadfile($id) {

        $stfk =Stocks::find($id);

        $file = Input::file("file");
       $fileName = $file->getClientOriginalName() ;

             $path=storage_path();  


        $stfk->file = $fileName;
        $stfk->st_status ='1';

        $stfk->path_to_file =$path;
        $stfk->name_on_disk = basename($path);

        $stfk->save();

        Session::flash('message', 'Successfully updated.');
       return View::make('stock.index');
    }



        public function getfile($file) 
    {                          
            $file_path = storage_path() . "/" . $file;                        
            return Response::download($file_path);
      }

view

<a class="btn btn-danger" title="" data-toggle="tooltip"  href="'.url('stock/file',$row->file).$row->fileName.'" target="_blank"><i class="fa fa-download"> </i></a>

please help me to get rid of this issue am using laravel 4.2

2

There are 2 answers

0
narayansharma91 On

It should be like this on your routes file.

Route::get('stock/{file}','stockTransferController@getfile');
1
Rp9 On

Use this

Route::get('stock/{file}','stockTransferController@getfile');

    <a class="btn btn-danger" title="" data-toggle="tooltip"  href="'.url('stock/file/{$row->file}').'" target="_blank"><i class="fa fa-download"> </i></a>