Trying to save an image field on a user using services, but for some reason it isn't saving in base64 So my server (running Drupal 7) is getting this information:

[field_picture] =&gt; Array
    (
        [und] =&gt; Array
            (
                [0] =&gt; Array
                    (
                        [file] =&gt; iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAYAAA..... (the rest of a huge base64 string)
                        [filename] =&gt; test.png
                        [filemime] =&gt; image/png
                        [target_uri] =&gt; test.png
                        [filepath] =&gt; public://
                        [mimeType] =&gt; image/png
                    )

            )

    )


This is to a user endpoint, and this is the only field that doesn't update.

The rest of what is sent to the server looks like this:

[field_description] =&gt; Array
        (
            [und] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [value] =&gt; 
                            [format] =&gt; 
                            [safe_value] =&gt; 
                        )

                )

        )

[uid] =&gt; 22
[roles] =&gt; Array
    (
        [2] =&gt; authenticated user
    )


And my AJAX to put this up:

    $.ajax({
        url: SITE_URL + "/" + ENDPOINT + "/user/" + localStorage.uid,
        type: 'PUT',
        crossDomain: true,
        headers: {
            'X-CSRF-Token': token
        },
        contentType: 'application/json',
        data: JSON.stringify(json),

...etc


The request doesn't fail (or at least it doesn't go to my error callback) - what is going on here and why isn't it saving?
You need to make two requests, the first you will POST the base64 encoded string of the file which in turn will return to you the file id, at which point you can make the second call to save the user entity with the file id on the field in question. I have a blog post about this here: http://tylerfrankenstein.com/code/drupal-services-file-create-example-json-and-jquery

Here's the gist of it (assuming your endpoint path is api):

// Get the file id...
$.ajax({
  type: "post",
  data: {
    "file":{
      "file": my_base_64_encoded_image_string,
      "filename": "my_image.jpg",
      "filepath": "public://my_image.jpg",
    }
  },
  url: 'https://www.example.com/api/file.json',
  dataType: 'json',
  success: function(result) {

    // Now that we have the file id, save it on the user entity.
    var userAccount = {
      field_picture: { und: [ { fid: result.fid } ] }
    };

    $.ajax({
      url: "https://www.example.com/api/user/" + localStorage.uid,
      type: 'PUT',
      crossDomain: true,
      headers: {
          'X-CSRF-Token': token
      },
      contentType: 'application/json',
      data: JSON.stringify(userAccount)
    });

  }
});