title: AJAX Image Upload to Wordpress
body: <p>So I'm trying to allow users to upload an image from the front end of a Wordpress site.  I don't want them to have to sign up for an account or anything.  I'm using the jQuery plugin AJAXUpload to handle everything on the front end and it's working perfectly.  However whenever I call into Wordpress's AJAX functions, I don't get a response at all.  I've tried simply die-ing out a string and I still don't receive anything back.  </p>
  
  <p>Here's the code I have in the Wordpress backend that's supposed to accept the image upload.</p>
  
  <pre><code>if( !function_exists( 'ni_handle_file_upload' ) ){
  function ni_handle_file_upload() {
      //global $wpdb, $global_contest_settings;
      die(json_encode("test"));
      /*if ($_FILES) {
          require_once(ABSPATH . "wp-admin" . '/includes/image.php');
          require_once(ABSPATH . "wp-admin" . '/includes/file.php');
          require_once(ABSPATH . "wp-admin" . '/includes/media.php');
  
          $attachment_ids = array();
          foreach ($_FILES as $file =&gt; $array) {
              // check to make sure its a successful upload
              if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) {
                  die(json_encode(array(
                      "status" =&gt; "error",
                      "message" =&gt; "There was an error uploading the file."
                  )));
              }
  
              $attachment_ids[] = media_handle_upload( $file );
          }
      }
  
      die(json_encode(array(
          "status" =&gt; "success",
          "message" =&gt; "File uploaded successfully",
          "attachment_ids" =&gt; $attachment_ids
      )));*/
  }
  add_action( 'wp_ajax_handle_file_upload', 'ni_handle_file_upload' );
  add_action( 'wp_ajax_nopriv_handle_file_upload', 'ni_handle_file_upload' );
  }
  </code></pre>
  
  <p>And here is the JS I'm using on the front end to upload the file.</p>
  
  <pre><code>new AjaxUpload('thumb', {
  action: Contest.ajaxurl,
  name: 'image',
  data: {
      action: "handle_file_upload"
  },
  autoSubmit: true,
  responseType: "json",
  onSubmit: function(file, extension) {
      $('div.preview').addClass('loading');
  },
  onComplete: function(file, response) {
      thumb.load(function(){
          $('div.preview').removeClass('loading');
          thumb.unbind();
      });
      thumb.attr('src', response);
  }
  });
  </code></pre>
  
  <p>I've breakpointed throughout the JS and everything is OK, except for the fact that the onComplete event never fires and from what I can tell in the Network tab in Chrome, it makes the call out to Wordpress's admin-ajax.php, but it never gets a response back even when I'm just running one line of code.  What have I missed here?</p>