title: File not Uploading using Ajax in cakephp
body: <p>Am trying to upload an image using Ajax to server. I know the code to upload file using Cakephp, but first i just want to make sure that data/file is uploaded to server for sure by printing the formdata. But it seems that only the data i typed in the textbox is posted and not the file i selected. Any help would be appreciated. Linking the code below</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form id="newcatform" method="post" action="&lt;?php echo($this-&gt;Html-&gt;url(array('controller'=&gt;'ajaxadmin','action'=&gt;'newcategory'))); ?&gt;" enctype="multipart/form-data"&gt;
              &lt;div class="row" style="margin-top:20px;"&gt;
                  &lt;div class="col-md-12"&gt;
                      &lt;div class="panel panel-default"&gt;
                          &lt;div class="panel-heading"&gt;
                              &lt;h5&gt;Create Category&lt;/h5&gt;
                          &lt;/div&gt;
                          &lt;div class="panel-body"&gt;
                                  &lt;div class="form-group" style="padding:15px 0px;"&gt;
                                      &lt;label class="col-lg-3 control-label"&gt;Category Name&lt;/label&gt;
                                      &lt;div class="col-lg-9"&gt;
                                          &lt;input type="text" name="newcatname" id="newcatname" class="form-control input-sm valid"&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group" style="padding:15px 0px;"&gt;
                                      &lt;label class="col-lg-3 control-label"&gt;Category Image&lt;/label&gt;
                                      &lt;div class="col-lg-9"&gt;
                                          &lt;input type="file" name="newcatimage" id="newcatimage"&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="form-group" style="padding:15px 0px;"&gt;
                                      &lt;label class="col-lg-3 control-label"&gt;&amp;nbsp;&lt;/label&gt;
                                      &lt;div class="col-lg-9"&gt;
                                          &lt;button type="submit" class="btn btn-primary btn-sm"&gt;Create&lt;/button&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>$('#newcatform').on('submit',(function(e) {
          e.preventDefault();
          var formData = new FormData($('#newcatform')[0]);
          //formData.append("type", $("#newcatname").val());
          //formData.append("content", $("#newcatimage").prop('files')[0]);
          $.ajax({
              type:'POST',
              url: $(this).attr('action'),
              data:formData,
              cache:false,
              contentType: false,
              processData: false,
              success:function(data){
                  console.log("success");
                  console.log(data);
              },
              error: function(data){
                  console.log("error");
                  console.log(data);
              }
          });
      }));
  </code></pre>
  
  <p>In Action Controller</p>
  
  <pre><code>if($this-&gt;request-&gt;is('post')){
              $this-&gt;Layout=null;
              $this-&gt;autoRender=false;
              $formdata=$this-&gt;request-&gt;data;
              print_r($formdata);
              exit;
          }
  </code></pre>