O'Reilly logo

Laravel Application Development Blueprints by Halil İbrahim Yılmaz, Arda Kılıçdağı

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a secure form for file upload

Now we should make an upload form for our image site. We must make a view file, which will be loaded over a controller.

  1. First, open up app/routes.php, remove the line starting with Route::get() that comes with Laravel, and add the following lines:
    //This is for the get event of the index page
    Route::get('/',array('as'=>'index_page','uses'=>'ImageController@getIndex'));
    //This is for the post event of the index.page
    Route::post('/',array('as'=>'index_page_post','before' =>'csrf', 'uses'=>'ImageController@postIndex'));

    The key 'as' defines the name of the route (like a shortcut). So if you make links to the routes, even if the URL changes for the route, your links to the application won't be broken. The before ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required