title: Uploading file with ajax not working
body: <p>I am creating my own little CMS and need to upload files and images. I already tried to implement the blueimp uploader but to no avail.</p>
  
  <p>I want to send the formData via a jquery script to my CMS. In the PHP code (receive) I check the content type and then want to pass the file to a function (processing). In the console I can see that jquery sends the attached file, but I get empty $_POST and $_FILES arrays in PHP.</p>
  
  <p>I can´t use a GET request as these are restricted by my CMS.</p>
  
  <p>Here´s the code snippets I have:</p>
  
  <p>HTML form:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data"&gt;
      &lt;input type="file" name="import_file" id="import_file" /&gt;
      &lt;button id="import_send" value="import"&gt;Import&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>jquery:</p>
  
  <pre><code>$(document).ready(function(){
      $('#import_send').on('click', function(e){
          e.preventDefault();
          var data = new FormData();
          data.append($('#import_file')[0].files[0].name, $('#import_file')[0].files[0]);
          $.ajax({
              url: window.location.href,
              data: data,
              processData: false,
              type: 'POST',
              contentType: 'multipart/form-data',
              mimeType: 'multipart/form-data',
              success: function (ret) {
                  alert(ret);
              }
          });
      });
  });
  </code></pre>
  
  <p>PHP (receive):</p>
  
  <pre><code>&lt;?php
      function do_control(){
          if ($_SERVER['CONTENT_TYPE']){
              if (strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false){
                  $in = $_FILES;
                  $method = 'on_upload';
                  if ($bothandler-&gt;get_by_name('upload_bot', true) == true){
                      $bothandler-&gt;trigger($method, $in);
                  }
              }
          }
      }
  ?&gt;
  </code></pre>
  
  <p>PHP (processing):</p>
  
  <pre><code>&lt;?php
      public function on_upload($in){
              if ($in['type'] == 'application/zip'){
                  if (!file_exists('../extension/'.$in['name'])){
                      move_uploaded_file($in['tmp_name'], '../extension/'.$in['name']);
                  }
              }
              if ($in['type'] == 'image/jpeg' || $in['type'] == 'image/png' || $in['type'] == 'image/bmp' || $in['type'] == 'image/gif'){
                  if (!file_exists('../images/'.$in['name'])){
                      move_uploaded_file($in['tmp_name'], '../images/'.$in['name']);
                  }
              };
              echo 'loaded';
      }
  ?&gt;
  </code></pre>
  
  <p>This is what is written in the request header:</p>
  
  <pre><code>Accept  */*
  Accept-Encoding gzip, deflate
  Accept-Language de,en-US;q=0.7,en;q=0.3
  Cache-Control   no-cache
  Connection  keep-alive
  Content-Length  316648
  Content-Type    multipart/form-data
  Cookie  f23476c1b4331c112ea6010733733bd5=icg8d641nv2e79lm3ce7p39h06; 78fad9eff80cd47c7c23dc899cb72eea=b38c1atf7fbqk4jc29p3bej964; silent_admin_session=b38c1atf7fbqk4jc29p3bej964
  DNT 1
  Host    www.abc.com
  Pragma  no-cache
  Referer http://www.abc.com/index.php5
  User-Agent  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0
  X-Requested-With    XMLHttpRequest
  </code></pre>
  
  <p>This is what´s in the post</p>
  
  <pre><code>-----------------------------24138208746564 Content-Disposition: form-data; name="192184_10150119104647532_7869997_o.jpg"; filename="192184_10150119104647532_7869997_o.jpg" Content-Type: image/jpeg
  ***
  </code></pre>
  
  <p>The PHP script throws an error as it does not get any data from $_FILES as this is empty.
  It doesn´t matter if I am trying to upload an image or a zip file which is definitely not bigger then the allowed upload_max_filesize.</p>
  
  <p>As an additional problem I can´t send files bigger than 2M. I already tried to include</p>
  
  <pre><code>php_value upload_max_filesize 40M
  php_value post_max_size 42M
  </code></pre>
  
  <p>in the htaccess file but then I get a 500 error. I also tried to do this with a user.ini file</p>
  
  <pre><code>upload_max_filesize=40M
  post_max_size=42M
  </code></pre>
  
  <p>but it seems to have no effect.</p>