我似乎遇到了墙,试图使用 Phonegap 应用程序和服务器端的 ASP.net 页面将照片上传到服务器。我已经多次检查了我的代码,编写 aspx 服务的人也检查了他们身边的事情。我正在使用文件传输和文件插件,并且在使用代码 1 调用上传方法时发生应用程序错误。我首先尝试使用简单的请求 AJAX 在服务器中上传图像并且它可以工作。但是当使用phonegap插件时,它不起作用。这是我的代码:
function getImage() {
navigator.camera.getPicture(uploadPhoto, function(message) {
alert('get picture failed');
}, {
quality: 100,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
});
}
function uploadPhoto(imageURI) {
alert("entrer dans uploadPhoto");
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
console.log(options.fileName);
var params = new Object();
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
var ft = new FileTransfer();
ft.upload(imageURI, "http://192.168.100.165/ProjetCourtageServerSide/DownloadDocumentSinistre.aspx", function(result){
alert(JSON.stringify(result));
}, function(error){
alert(JSON.stringify(error));
}, options);
}