这是我的代码请帮帮我这是我的代码...我在.net中的web服务如何使用java脚本传递图像并获取.net Web服务并存储在Folder中并再次获取它。我试过这个Min。 3个小时,但我没有得到解决方案,请帮助我...
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
// Retrieve image file location from 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);
}
如果您有其他解决方案,请告诉我...... 感谢
答案 0 :(得分:0)
您需要使用函数来获取实际路径
window.resolveLocalFileSystemURI(imguri, resolveOnSuccess, fsFail);
所以你的代码看起来像
var fileuri ="";
function uploadPhoto(imageURI) {
window.resolveLocalFileSystemURI(imageURI, resolveOnSuccess, fsFail)
var fileName = fileuri.substr(fileuri.lastIndexOf('/') + 1);
options.fileName = fileName;
// your remaining code
}
function resolveOnSuccess(entry) {
fileuri = entry.toURL();
//console.log(fileuri);
}
function fsFail(message) {
alert(message);
}