title: AJAX file input image upload in Cakephp
body: <p>I'm uploading an image file via AJAX ajaxFileUpload plugin which uses iframe to submit the file. I have successfully uploaded the file to my controller and I can see the tmp_name, name, error = 0 etc but when I use this $this->data['Card']['tmp_name'], with move_uploaded_file it always returns false regardless of the path being correct...I'm not sure from this point onwards.</p>
  
  <p>Below is my code so far for view file...</p>
  
  <pre><code>function ajaxFileUpload() {
      $.ajaxFileUpload({
          url: '/cards/ajaxFrontCardUpload',
          secureuri: false,
          fileElementId: 'CardUploadFront',
          dataType: 'json',
          success: function (data, status) {
              console.log(data);
              $('#uploadFrontImage').attr('src', data.tmp_path);
          },
          error: function (data, status, e) {
              alert(e);
          }
      })
      return false;
  }
  
  $('#CardUploadFront').live('change', function () {
      ajaxFileUpload();
  });
  
  echo $form-&gt;file('Card.uploadFront', array('class'=&gt;'file'));
  </code></pre>
  
  <p>Below is the controller function:</p>
  
  <pre><code>public function ajaxFrontCardUpload() {
          $this-&gt;layout = 'ajax';
          $tmp_name = $this-&gt;data['Card']['uploadFront']['tmp_name'];
          $tmp_name = $this-&gt;data['Card']['uploadFront']['tmp_name'].'/'.$this-&gt;data['Card']['uploadFront']['name'];
          $json_response['tmp_path'] = '/img/cards/temp/'.time().'.png';
          if(move_uploaded_file($tmp_name, $json_response['tmp_path'])){
              $json_response['response'] = 'true';
          }else{
              $json_response['response'] = 'false';
          }
          $this-&gt;set(compact('json_response'));
      }
  </code></pre>
  
  <p>Any ideas guys?</p>