title: Basic CakePHP 2.0 image upload
body: <p>I'm trying tu upload an avatar related to an user record but I'm not sure how to do it, I think I should use <code>File</code> and <code>Folder</code> <code>Utility</code> but I'm not sure on how I should use it.</p>
  
  <p>I have an <code>avatar</code> field in my <code>users</code> db table where I should insert the path of my users's avatar, because the avatar is unique to every user I thought to use the <code>avatar</code> column right inside the <code>users</code> table, is it the right way or should I do something specific for images?</p>
  
  <p>I've wrote this but it won't work:</p>
  
  <pre><code>// in my user edit view where I upload the image (avatar)
  $file = new File ($this-&gt;request-&gt;data['User']['avatar']); // error here
  $ext = $file-&gt;ext();
  $filename = $this-&gt;User-&gt;id.$ext;
  $image = $file-&gt;read();
  $file-&gt;close();
  $file = new File (WWW_ROOT.'img/avatar/'.$filename, true, 777);
  $file-&gt;write($image);
  $file-&gt;close();
  $this-&gt;request-&gt;data['User']['avatar'] = $filename;
  </code></pre>
  
  <p>this code returns the error at the first row I've reported, where I create the <code>File</code> by passing <code>$this-&gt;request-&gt;data['User']['avatar']</code> array:</p>
  
  <pre><code>Warning (2): dirname() expects parameter 1 to be string, array given
  Warning (2): is_dir() expects parameter 1 to be string, array given
  Warning (2): basename() expects parameter 1 to be string, array given
  </code></pre>
  
  <p>Does exists some working example for <code>CakePHP 2.0</code>?</p>