title: File upload in Cakephp 3.3
body: <p>I am trying to store an image in cakephp 3.0. I am only able to save the filename in db, however, unable to store the actual file on the server. Need help</p>
  
  <p>Form:</p>
  
  <pre><code>        echo $this-&gt;Form-&gt;create('User', array('url' =&gt; array('action' =&gt; 'create'), 'enctype' =&gt; 'multipart/form-data'));
          echo $this-&gt;Form-&gt;input('upload', array('type' =&gt; 'file'));
  </code></pre>
  
  <p>Images controller:</p>
  
  <pre><code> */
  public function add()
  {
      $image = $this-&gt;Images-&gt;newEntity();
      //Check if image has been uploaded
      if(!empty($this-&gt;request-&gt;data['Images']['upload']['name']))
      {
          $file = $this-&gt;request-&gt;data['Images']['upload']; //put the data into a var for easy use
  
          $ext = substr(strtolower(strrchr($file['name'], '.')), 1); //get the extension
          $arr_ext = array('jpg', 'jpeg', 'gif'); //set allowed extensions
  
          //only process if the extension is valid
          if(in_array($ext, $arr_ext))
          {
              //do the actual uploading of the file. First arg is the tmp name, second arg is
              //where we are putting it
              move_uploaded_file($file['tmp_name'], WWW_ROOT . 'img' . $file['name']);
  
              //prepare the filename for database entry
              $this-&gt;data['Images']['image'] = $file['name'];
          }
      }
  
      if ($this-&gt;request-&gt;is('post')) {
          $image = $this-&gt;Images-&gt;patchEntity($image, $this-&gt;request-&gt;data);
          if ($this-&gt;Images-&gt;save($image)) {
              $this-&gt;Flash-&gt;success('The image has been saved.');
              return $this-&gt;redirect(['action' =&gt; 'index']);
          } else {
              $this-&gt;Flash-&gt;error('The image could not be saved. Please, try again.');
          }
      }
      $this-&gt;set(compact('image'));
      $this-&gt;set('_serialize', ['image']);
  }
  </code></pre>