cordova - I cannot send image in .net webservice using javascript -
this code please me code... web service in .net how pass image using java script , in .net web service , store in folder , again. had tried min. 3 hours failed solution please me...
// wait cordova load // document.addeventlistener("deviceready", ondeviceready, false); // cordova ready // function ondeviceready() { // retrieve image file location specified source navigator.camera.getpicture(uploadphoto, function(message) { alert('get picture failed'); }, { quality: 50, destinationtype: navigator.camera.destinationtype.file_uri, sourcetype: navigator.camera.picturesourcetype.photolibrary } ); } function uploadphoto(imageuri) { var options = new fileuploadoptions(); options.filekey="file"; options.filename=imageuri.substr(imageuri.lastindexof('/')+1); options.mimetype="image/jpeg"; var params = {}; params.value1 = "test"; params.value2 = "param"; options.params = params; var ft = new filetransfer(); alert(imageuri); ft.upload(imageuri, encodeuri("http://www.gameworld.co.in/useimage"), win, fail, options); } function win(r) { console.log("code = " + r.responsecode); console.log("response = " + r.response); console.log("sent = " + r.bytessent); } function fail(error) { alert("an error has occurred: code = " + error.code); console.log("upload error source " + error.source); console.log("upload error target " + error.target); }
if have other solution please tell me... thanks
you need make use of function actual path using
window.resolvelocalfilesystemuri(imguri, resolveonsuccess, fsfail);
so code like
var fileuri =""; function uploadphoto(imageuri) { window.resolvelocalfilesystemuri(imageuri, resolveonsuccess, fsfail) var filename = fileuri.substr(fileuri.lastindexof('/') + 1); options.filename = filename; // remaining code } function resolveonsuccess(entry) { fileuri = entry.tourl(); //console.log(fileuri); } function fsfail(message) { alert(message); }
Comments
Post a Comment