Created
August 1, 2010 18:30
-
-
Save dsifry/503612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function post_pic_data(user,pass,storagevariable) { | |
data = localStorage.getItem(storagevariable); | |
if (data == null) { | |
alert("No picture selected"); | |
} | |
alert("About to send data"); | |
var dis = this; | |
var url = "http://example.com/newmobile.php"; | |
var boundary = "----WebKitFormBoundary"; | |
var datastr = boundary + "\n" + 'Content-Disposition: form-data; name="activity[photo_attributes][pic]"; filename="image.jpg"' + | |
"\nContent-Type: image/jpeg\n\n" + data + boundary; | |
console.log(datastr); | |
x$('#results').xhr(url, | |
{ | |
headers: [ | |
{ | |
name: "Authorization", | |
value: "Basic " + btoa(user + ":" + pass) | |
}, | |
{ | |
name: "Content-Type", | |
value: "multipart/form-data; boundary=" + boundary | |
}, | |
{ | |
name: "Cache-Control", | |
value: "no-cache" | |
}, | |
], | |
data: datastr, | |
method: "post", | |
async: true, | |
callback:function(incoming) { | |
alert(incoming); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment