HTML
Choose Image
Upload
Add
Choose Image
Upload
Add
.controller(‘HomeCtrl’, function($scope, $http) {
// //////////////////////////////////////////////////////
// checking online status and host
// //////////////////////////////////////////////////////
$http.get(host + ‘api.php?online’)
.then(
function(e) {
console.log(e);
if (!e.data) {
var input = prompt(“Unknown host please enter host name”);
store.set(“host”, input);
host = ‘http://’ + input + ‘/mp/’;
}
},
function(e) {
var input = prompt(“Unknown host please enter host name”);
store.set(“host”, input);
host = ‘http://’ + input + ‘/mp/’;
}
);
////////////////////////////////////////
$http.get(host + ‘api.php?select_all_wims’)
.then(
function(suc) {
$scope.wims = suc.data;
$scope.host = host;
console.log(suc.data);
},
function(err) {
});
$scope.search = '';
})
.controller('MissingCtrl', function($scope, $http, $cordovaCamera, $cordovaFile, $cordovaFileTransfer) {
var image_to_upload;
$scope.take_picture = function() {
var options = {
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
targetWidth: 200,
targetHeight: 200,
correctOrientation: true
};
$cordovaCamera.getPicture(options)
.then(function(imageData) {
image_to_upload = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
alert(err);
});
}
$scope.add = function(data) {
var option = {
fileKey: 'image_name',
params: { 'name': data.name, 'age': data.age, 'contact_number': data.contact_number, 'address': data.address, 'insert': '' }
};
$cordovaFileTransfer.upload("http://localhost/mp/api.php", image_to_upload, option)
.then(
function(success) {
//window.location.href = "#/menu/success_page";
alert("success");
},
function(error) {
alert("Error" + JSON.stringify(error));
},
function(progress) {
}
);
}
)}