title: Laravel 4 Form: Image file upload with text fields
body: <p>I would like to design a form in Laravel which takes an image the User has selected, uploads it to the server and stores the image path in a <code>'image'</code> field and also accepts a <code>'text'</code> field which describes the image.  I do not know how to store both the text field and image as an array to pass to the controller. </p>
  
  <p><strong>The Form</strong></p>
  
  <pre><code>&lt;div class="form-group"&gt;
  {{ Form::label('description', trans('main.poster')) }}
  {{ Form::text('description', Input::old('poster'), array('class' =&gt; 'form-control')) }}
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
  {{ Form::file('image','files' =&gt; true) }}
  &lt;/div&gt;
  &lt;button type="submit" class="btn btn-success"&gt;{{ trans('dash.update') }}&lt;/button&gt;
  </code></pre>
  
  <p><strong>Controller</strong> </p>
  
  <pre><code>public function store()
  {
  
  $input = array('image' =&gt; Input::file('image'));
  
      if ( ! $this-&gt;validator-&gt;setRules('image')-&gt;with($input)-&gt;passes())
      {
          return Redirect::back()-&gt;withErrors($this-&gt;validator-&gt;errors());
      }
  
      $this-&gt;title-&gt;uploadImage($input);
  
      return Redirect::back()-&gt;withSuccess( trans('main.uploaded image success')        );
  </code></pre>
  
  <p><strong>Upload image</strong></p>
  
  <pre><code>public function uploadImage(array $input)
  {   
   $name  = str_random(25);
      $insert = array('image' =&gt; asset('assets/images/'.$name.'.jpg'), );
  
      $this-&gt;images-&gt;saveTitleImage($input, $name);
  
  
  }
  </code></pre>
  
  <p><strong>Save image path</strong></p>
  
  <pre><code>public function saveTitleImage($input, $name)
  {
      $encoded = Imagine::make($input['image']-&gt;getRealPath())
          -&gt;encode('jpg');
  
      Imagine::make($encoded)-&gt;save(public_path('assets/images/'.$name.'.jpg'));  
  }
  </code></pre>