Reputation: 411
I have the following JavaScript code to get contact name and thumbnail from the people app.
var picker = new Windows.ApplicationModel.Contacts.ContactPicker();
picker.commitButtonText = "Select";
picker.pickSingleContactAsync().done(function (contact) {
if (contact !== null) {
var name = contact.name
contact.getThumbnailAsync().done(function (thumbnail) {
if (thumbnail.size > 0) {
var imageBlob = window.URL.createObjectURL(thumbnail);
document.getElementById("img").src = imageBlob;
WinJS.xhr({ url: "http://host?name=" + name }).done(
function completed(rss) {
},
function error(request) {
// handle error conditions.
},
function progress(request) {
// report on progress of download.
}
);
}
});
}
I know ho to send the name to a web server but how to send the thumbnail ?
Can somebody provide a sample code.
Thank you.
Upvotes: 0
Views: 421
Reputation: 638
You can do a HTTP POST with WinJS.xhr(). Here's an example:
How to upload binary data with WinJS.xhr
You just set these options: type: "POST", url: <URI of the website>, data: blob
. Create the blob first, as shown in the example.
Upvotes: 1