Learn more about file upload and AJAX in Laravel 5 by reading our popular book: Laravel 5 Cookbook.

Learn how to create file upload with Laravel 4

File upload laravel

We discussed before form creation and validation but file upload input is a bit different. Let’s create our first file upload with laravel.

Before retrieving uploaded file data, We need to setup a simple form and two routes. The first route is for form view and the other route for form submission.

<!--app/views/form.blade.php-->
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>
   Laravel
  </title>
 </head>
 <body>
  {{ Form::open(array('url'=>'form-submit','files'=>true)) }}

  {{ Form::label('file','File',array('id'=>'','class'=>'')) }}
  {{ Form::file('file','',array('id'=>'','class'=>'')) }}
  <br/>
  <!-- submit buttons -->
  {{ Form::submit('Save') }}

  <!-- reset buttons -->
  {{ Form::reset('Reset') }}

  {{ Form::close() }}
 </body>
</html>
//app/routes.php
Route::get('form', function(){
 return View::make('form');
});

Route::any('form-submit', function(){
 var_dump(Input::file('file'));
});

Basically, Uploaded files aren’t stored in the $_GET or $_POST array but they stored in t