cordova - 使用 phonegap 应用程序上传图像
问题描述
我似乎遇到了墙,试图使用 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);
}
解决方案
我认为您的问题是以错误的方式提出的,您可以尝试就您的实际问题提供更多说明吗?下次您发布问题时,可能会尝试隐藏您的 IP 地址和服务 URL!
推荐阅读
- sql - SQL 使用另一个表中的值更新表
- azure-devops - Devops:错误 CS0103:当前上下文中不存在名称“Windows”
- c - 为什么线程在共享局部变量时有自己的堆栈?
- java - 线程卡在应用程序中
- python-3.x - 在 Pi3 和 Python 3.6 中使用两个 MPR121 HAT 时出现问题
- javascript - Javascript链接选项到else if
- ruby - 一次获取中的 Ruby 超时
- html - 如果缩放,Bootstrap 4 中的一行表格无响应
- python - 脚本未读取文件末尾换行符
- python - 如何将tanh添加到keras中的一个嵌入层