Reputation: 142
Below is the piece of code i have used:
JSON.stringify({
request:
{
"Ticket": "String content",
"Picture": {
"Name": "blabla",
"ImgData": "blabla",
},
}
});
i have picture , i captured with phonegap and i wanna post it with json. is it possible ?
Upvotes: 0
Views: 410
Reputation: 53371
if you want to upload it inside json data you'll need to send the image encoded in base64, for that use the destinationType: Camera.DestinationType.DATA_URL
when you take the picture
Upvotes: 0
Reputation: 2701
function uploadPhoto(imageURI) {
var imagefile = imageURI;
var ft = new FileTransfer();
var options = new FileUploadOptions();
options.fileKey="vImage1";
options.fileName=imagefile.substr(imagefile.lastIndexOf('/')+1);
options.mimeType="image/jpeg";
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
ft.upload(imagefile, your_service_url, win, fail, options);
}
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
//alert($.parseJSON(r.response))
}
function fail(error) {
console.log("Response = " + error.code);
}
Upvotes: 1