Javascript 从Cordova摄像头插件上传图像
我正在尝试上传使用摄像头插件拍摄的图像,以及使用AJAX的纬度、纬度和电话号码参数 这是我的密码:Javascript 从Cordova摄像头插件上传图像,javascript,ajax,cordova-plugins,cordova-plugin-file,Javascript,Ajax,Cordova Plugins,Cordova Plugin File,我正在尝试上传使用摄像头插件拍摄的图像,以及使用AJAX的纬度、纬度和电话号码参数 这是我的密码: const launchCamera = () => { navigator.camera.getPicture(onSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI,
const launchCamera = () => {
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
cameraDirecetion: Camera.Direction.FRONT,
}
);
function onSuccess(imageUri) {
function getFileEntry(imageUri) {
window.resolveLocalFileSystemURL(imageUri, function success(fileEntry) {
// Do something with the FileEntry object, like write to it, upload it, etc.
// writeFile(fileEntry, imgUri);
hideSelfieUploadModal();
var selfie_log_id = "1";
function getPosition() {
var options = {
enableHighAccuracy: true,
maximumAge: 3600000
}
var PhoneONLocation = navigator.geolocation.getCurrentPosition(onSuccess, onError, options);
function onSuccess(position) {
var longitude = String(position.coords.longitude);
var latitude = String(position.coords.latitude);
var number = "0787";
var submitImage = {
"async": true,
"crossDomain": true,
"url": serverUrl + 'submit-image/',
"method": "POST",
"headers": {
"Accept": "*/*",
"Content-Type": "application/json; charset=UTF-8",
},
"processData": false,
"success": function() {
var success_timeout = setTimeout(phoneONLocationReporting, 30000)
},
"error": function() {
var success_timeout = setTimeout(phoneONLocationReporting, 30000)
},
"data": "{\n\t\"selfie_request_log_id\": \"" + selfie_log_id + "\", \n\t\"selfie_image\":\"" + fileEntry + "\",\n\t\"driver_number\":\"" + phone_number + "\", \n\t\"latitude\":\"" + latitude + "\",\n\t\"longitude\":\"" + longitude + "\"\n}"
}
$.ajax(submitImage).done(function(response){
console.log(response.message);
});
};
function onError(error) {
console.log('code: ' + error.code + '\n' + 'message: ' + error.message + '\n');
}
}
getPosition();
});
}
}
function onFail(message) {
alert('Failed because: ' + message);
}
}
捕获图像后不会发生任何情况,因为在成功捕获图像后,应继续上载文件。我无法理解我在哪里做错了事情,因为我在前端没有看到任何错误,后端也没有看到任何错误,这意味着请求尚未发出