title: Trouble with image upload {Ajax,php,Filereader}
body: <p>When I upload the image the server return "empty".</p>
  
  <p>What i need to change from server or client to work?
  I want to upload only one image and i dont have form etc
  HTML:</p>
  
  <p>input id="imgupload" type="file" value="Upload"</p>
  
  <p>Client Side:  </p>
  
  <pre><code>var reader = new FileReader();
                              function readURL(input) {
                                  var fileTypes = ['jpg', 'jpeg', 'png'];
                                  var extension = input.files[0].name.split('.').pop().toLowerCase(),
                                      isSuccess = fileTypes.indexOf(extension) &gt; -1;
                                  if (isSuccess) {
                                      reader.onload = function (e)
                                      {
                                          $('#img').attr('src', e.target.result);
                                          $('#imguploadinput').hide();
                                          $('#imguploadmenu').show();
                                          $( "#imgsave" ).click(function() {
                                              imagesave(e.target.result);
                                          });
                                      }
                                      reader.readAsDataURL(input.files[0]);
                                  }
                                  else{
                                      imagedelete();
                                      $('#error').html("file error!");
                                  }
                              }
                              function imagesave(img){
                                  //$('#imguploadmenu').hide();
                                  $.ajax({
                                      url: "system/profile/uploadimage.php",
                                      type: "POST",
                                      data: {img:img},
                                      success: function (data) {
                                          $("#imgSpinner1").hide();
                                          $('#error').html(data);
                                      },
                                      beforeSend: function() {
                                          $("#imgSpinner1").show();
                                      }
                                  });
                              }
  </code></pre>
  
  <p>Server Side:</p>
  
  <pre><code>$imageInfo = getimagesize($_FILES['img']['tmp_name']);
  if ($imageInfo['mime'] == ("image/png") || $imageInfo['mime'] == ("image/jpeg")
      || $imageInfo['mime'] == ("image/gif") ||
      $imageInfo['mime'] == ("image/bmp")) {
      echo "ok";
      }
  else
  {
      if(empty($_FILES['img'])) echo "empty";
      else echo "no empty";
  }
  </code></pre>