title: file upload in cakephp 2.3
body: <p>I'm new in cakephp and i'm trying to create a simple file upload with cakephp 2.3 here is my controller</p>
  
  <pre><code>public function add() {
      if ($this-&gt;request-&gt;is('post')) {
          $this-&gt;Post-&gt;create();
             $filename = WWW_ROOT. DS . 'documents'.DS.$this-&gt;data['posts']['doc_file']['name']; 
             move_uploaded_file($this-&gt;data['posts']['doc_file']['tmp_name'],$filename);  
  
  
          if ($this-&gt;Post-&gt;save($this-&gt;request-&gt;data)) {
              $this-&gt;Session-&gt;setFlash('Your post has been saved.');
              $this-&gt;redirect(array('action' =&gt; 'index'));
          } else {
              $this-&gt;Session-&gt;setFlash('Unable to add your post.');
          }
       }
   }
  </code></pre>
  
  <p>and my add.ctp</p>
  
  <pre><code>echo $this-&gt;Form-&gt;create('Post');
  echo $this-&gt;Form-&gt;input('firstname');
  echo $this-&gt;Form-&gt;input('lastname');
  echo $this-&gt;Form-&gt;input('keywords');
  echo $this-&gt;Form-&gt;create('Post', array( 'type' =&gt; 'file'));
  echo $this-&gt;Form-&gt;input('doc_file',array( 'type' =&gt; 'file'));
  echo $this-&gt;Form-&gt;end('Submit')
  </code></pre>
  
  <p>it saves firstname, lastname, keywords, and the name of the file in DB , but the file which i want to save in app/webroot/documents is not saving ,  can anyone help ? Thanks</p>
  
  <blockquote>
    <p><strong>Update</strong></p>
    
    <p>thaJeztah i did as u said but it gives some errors here is controller if i'm not wrong</p>
  </blockquote>
  
  <pre><code>public function add() {
       if ($this-&gt;request-&gt;is('post')) {
           $this-&gt;Post-&gt;create();
              $filename = WWW_ROOT. DS . 'documents'.DS.$this-&gt;request-&gt;data['Post']['doc_file']['name']; 
             move_uploaded_file($this-&gt;data['posts']['doc_file']['tmp_name'],$filename);
  
  
  
           if ($this-&gt;Post-&gt;save($this-&gt;request-&gt;data)) {
               $this-&gt;Session-&gt;setFlash('Your post has been saved.');
               $this-&gt;redirect(array('action' =&gt; 'index'));
           } else {
              $this-&gt;Session-&gt;setFlash('Unable to add your post.');
           }
       }
  
   }
  </code></pre>
  
  <blockquote>
    <p>and my add.ctp</p>
  </blockquote>
  
  <pre><code> echo $this-&gt;Form-&gt;create('Post', array( 'type' =&gt; 'file'));
   echo $this-&gt;Form-&gt;input('firstname'); echo $this-&gt;Form-&gt;input('lastname');
   echo $this-&gt;Form-&gt;input('keywords');
   echo $this-&gt;Form-&gt;input('doc_file',array( 'type' =&gt; 'file'));
   echo $this-&gt;Form-&gt;end('Submit') 
  </code></pre>
  
  <blockquote>
    <p>and the errors are</p>
    
    <p>Notice (8): Array to string conversion
    [CORE\Cake\Model\Datasource\DboSource.php, line 1005]</p>
    
    <p>Database Error Error: SQLSTATE[42S22]: Column not found: 1054 Unknown
    column 'Array' in 'field list'</p>
    
    <p>SQL Query: INSERT INTO first.posts (firstname, lastname, keywords,
    doc_file) VALUES ('dfg', 'cbhcfb', 'dfdbd', Array)</p>
    
    <p>and Victor i did your version too , it doesnt work too .</p>
  </blockquote>