@Sherbadshah wrote:
HTML
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) { } ); }
)}
php
<?php
include "library.php";
header("Access-Control-Allow-Origin:*");if(isset($insert)) { $image = "images/".$name.'_'.time().".jpg"; move_uploaded_file($_FILES['image_name']['tmp_name'],$image); insert("wim","'','$name','$age','$image','$contact_number','$address'"); } if(isset($online)) { echo true; } if(isset($select_all_wims)) { select("wim"); }
?>
Posts: 2
Participants: 2