title: upload images in "webroot/img" folder in cake php
body: <blockquote>
    <p></p>
  </blockquote>
  
  <p>"I want to upload images in webroot/img folder in cake php.but i am not able to
      suggest me some solution as i am new to cake php.I tried a lot of solutions from my
       side but nothing works.so help me"</p>
  
  <pre><code>my HomesController.php code as
  
  public function admin_add() {
  
      if ($this-&gt;request-&gt;is('post')) {
          $this-&gt;Home-&gt;create();
           $image = $this-&gt;request-&gt;data['Home']['image'];
           //$imageTypes = array("image/gif", "image/jpeg", "image/png");
           //$uploadFolder = "upload";
           //$uploadPath = WWW_ROOT . $uploadFolder;
  
           pr($this-&gt;request-&gt;data);
           //echo $image['type'];
           if ($this-&gt;Home-&gt;save($this-&gt;request-&gt;data)) {
              $this-&gt;Session-&gt;setFlash(__('The home has been saved.'));
              //echo pr($this-&gt;request-&gt;data);
              //echo die(debug($this-&gt;request-&gt;data));
              //return $this-&gt;redirect(array('action' =&gt; 'index'));
          } else {
              $this-&gt;Session-&gt;setFlash(__('The home could not be saved., tryagain '));
          }
      }
  }
  </code></pre>
  
  <blockquote>
    <p></p>
  </blockquote>
  
  <p>admin_add.ctp code is</p>
  
  <pre><code>&lt;div class="homes form"&gt;
  &lt;?php echo $this-&gt;Form-&gt;create('Home', array('type' =&gt; 'file')); ?&gt;
  &lt;fieldset&gt;
      &lt;legend&gt;&lt;?php echo __('Add Home content'); ?&gt;&lt;/legend&gt;
  &lt;?php
      echo $this-&gt;Form-&gt;input('title');
      echo $this-&gt;Form-&gt;input('body');
      echo $this-&gt;Form-&gt;input('image');
  ?&gt;
  &lt;/fieldset&gt;
  
  
  &lt;?php echo $this-&gt;Form-&gt;end(__('Submit')); 
  
  ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>
  
  <p>whilr running code i am not able to upload images and while printing image data 
  I m getting error.</p>
  
  <pre><code>Output:
  
  
  
  `Array
      (
      [Home] =&gt; Array
          (
              [title] =&gt; vhbk
               [body] =&gt; ,bjljbl.
               [image] =&gt; Array
              (
                  [name] =&gt; DSC03371.JPG
                  [type] =&gt; 
                  [tmp_name] =&gt; 
                  [error] =&gt; 1
                  [size] =&gt; 0
              )
  
           )
  
       )`
  </code></pre>