akimebless
akimebless

Reputation: 33

ErrorException (E_UNKNOWN) Route [file.upload] not defined

I got confused when I got this error.

Route [file.upload] not defined. (View: C:\Users\xxtajorb\xampp\htdocs\laravel-ixepms\app\views\layouts\master.blade.php)

I think that I did it all right but why I got this error. See what I am trying for. I can't load the my webpage because of this error. This file is to upload file. The below code is my master page which I think where the error occurs. I tried everything but still got this wrror

master.blade.php

<li class="xn-openable">
     <a href="{{ route('file.upload') }}"><span class="fa fa-files-o"></span> <span class="xn-text">Weekly Reports</span></a>
      <ul>
          <li><a href=""><span class="fa fa-file"></span> <span class="xn-text">Do My Reports</span></a></li>
      </ul>
  </li>

FileController.php

public function index()
    {
        return View::make('file.upload');
    }
    public function create()
    {
        //
    }
    public function store()
    {
            if (Input::hasFile('file')){
                //return 'file';
                $dest = 'uploadedFiles/';
                $name = str_random(6).''. Input::file('file')->getClientOriginalName();
                Input::file('file')->move($dest,$name);
                return Redirect::to('file.upload');
            }
    }

And lastly my routes.php

Route::group(['before' => 'auth'],function(){
      Route::get('home',['as'=> 'home','uses' => 'HomeController@index']);
      Route::controller('task','TaskController');
      Route::get('subtask/start/{id}','SubTaskController@getStart');
      Route::get('subtask/viewSubtaskDetails/{id}','SubTaskController@getViewSubtaskDetails');
      Route::get('comment/createComment/{id}','CommentController@getCreateComment');
      Route::post('setUser','TaskController@setUser');
      Route::post('saveAnswer','AssessmentController@saveAnswer');
      Route::resource('task','TaskController');
      Route::resource('subtask','SubTaskController');
      Route::resource('user','UserController');
      Route::resource('behavioralmain','BehavioralMainController');
      Route::resource('behavioralsub','BehavioralSubController');
      Route::resource('UserProfile','UserProfileController');
      Route::resource('comment','CommentController');
      Route::resource('worklog','WorklogController');
      Route::resource('assessment', 'AssessmentController');
      Route::resource('file', 'FileController');
 });

Please I need your help. I don't know what I will do know. I tried my effort but the error still there.

Upvotes: 0

Views: 862

Answers (1)

tanerkay
tanerkay

Reputation: 3930

What you want is this:

route('file.store')

Resource routes support the REST actions (index, edit, update, create, etc.), they don't allow any named action

Also your redirect should point to file.index I'm assuming, not file.upload

Upvotes: 1

Related Questions