Professional Documents
Culture Documents
Code
Code
Code
ready(function() {
console.log("pic upload.js loaded");
});*/
var img_path_new = null;
function capture() {
navigator.camera.getPicture(onSuccess, onFail, {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
correctOrientation: true,
});
function onSuccess(imageURI) {
var image = document.getElementById('fetched_img');
image.style.display = 'block';
image.src = imageURI;
// window.plugins.toast.show(imageURI, 'long', 'center');
console.log("Image Saved at ===> " + imageURI);
// $("#image_url").text(imageURI);
console.log(stamp);
//new file name
var ImageName = stamp + ".jpg";
console.log(ImageName);
window.resolveLocalFileSystemURL(source_url, function(file) {
window.resolveLocalFileSystemURL(absolutepath, function(destination) {
file.moveTo(destination, ImageName);
}, fail)
}, fail);
//document.getElementById("fetched_img").setAttribute("src",img_path_new);
window.setTimeout(
function() {
$("#fetched_img").attr('src', img_path_new);
}, 2000);
}
function onFail(message) {
console.log('Failed because: ' + message);
}
function upload_pic_remote() {
var id_user = localStorage.getItem("vone_ls");
console.log(id_user + "in pic_upload.js");
console.log(img_path_new + "in pic_upload.js");
$.support.cors = true;
$.ajax({
type: "POST",
url: "https://florid-pumps.000webhostapp.com/upload_pic.php", // Example
data: {
pic_path: pic_path,
id: id_user,
},
cache: false,
success: function(response) {
var responseData = jQuery.parseJSON(response);
console.log(responseData);
console.log(responseData.status);
//navigator.notification.alert("responseData.status");
alert("profile Pic Successfully Updated");
},
error: function(e) {
alert('Error: ' + e.message);
}
});
alert("profile Pic uploaded Successfully!!");
}