title: Laravel 4 - File Upload
body: <p>I have a Form where among other info, a user would upload an image. I want to store the path to the image on the database and save the image to the <code>public/img/</code> folder on the Server.</p>
  
  <p>The form was opened using: <code>{{ Form::open(['route'=&gt;'pizzas.store', 'files'=&gt;true]) }}</code>so that it would be able to POST files. Inspecting the HTML I have the folowing:</p>
  
  <pre><code>&lt;form method="POST" action="http://mypizza/pizzas" 
    accept-charset="UTF-8" enctype="multipart/form-data"&gt;
  </code></pre>
  
  <p>I can POST to my Controller and receive all the data from the Form as expected. The method handling the file is as follows:</p>
  
  <pre><code>public function store() {
      //TODO -  Validation
  
      $destinationPath = '';
      $filename        = '';
  
      if (Input::hasFile('image')) {
          $file            = Input::file('image');
          $destinationPath = '/img/';
          $filename        = str_random(6) . '_' . $file-&gt;getClientOriginalName();
          $uploadSuccess   = $file-&gt;move($destinationPath, $filename);
      }
  
  
      $pizza = Pizza::create(['name'       =&gt; Input::get('name'),
                             'price'       =&gt; Input::get('price'),
                             'ingredients' =&gt; Input::get('ingredients'),
                             'active'      =&gt; Input::get('active'),
                             'path'        =&gt; $destinationPath . $filename]);
  
      if ($pizza) {
          return Redirect::route('pizzas.show', $pizza-&gt;id);
      }
  
      //TODO - else
  }
  </code></pre>
  
  <p>When I select a File and Submit the Form, everything seems to work, except that no file is saved on the <code>/img</code> folder. The database registers the file path and name correctly.</p>
  
  <p>Running <code>dd($uploadSuccess);</code>right after the <code>if { ...}</code>block, I get the following:</p>
  
  <pre><code>object(Symfony\Component\HttpFoundation\File\File)#220 (2) {
    ["pathName":"SplFileInfo":private]=&gt; string(17) "/img\YZmLw7_2.jpg"
    ["fileName":"SplFileInfo":private]=&gt; string(12) "YZmLw7_2.jpg" }
  </code></pre>
  
  <p>What am I doing wrong?</p>