here is my controller js code
.controller(‘NewtopicCtrl’, function($scope, $state, $http, $cordovaCamera,$cordovaFileTransfer){
$scope.post = function(topic)
{
// var config = {parms:{title: $topic.title,name: $topic.name, message: $topic.message,file:$scope.imgURI} };
//topic[‘picture’] = $scope.imgURI;
$http.post(“http://localhost:8000/retrive.php?title="+topic.title+" & name=”+topic.name+" & message="+topic.message+"& file="+$scope.imgURI+"")
.success(function(response){
if(response==‘success’){
$state.go(‘tab.listview’);
}else{
alert(response);
}
});
}
$scope.takePicture = function(source)
{
var options = {
quality : 85,
destinationType : Camera.DestinationType.FILE_URL,
sourceType : source,
allowEdit : true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 180,
targetHeight: 180,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
}, function(err) {
// An error occured. Show a message to the user
});
}
});
and the php:
<?php header('Access-Control-Allow-Origin: *'); $server = "localhost"; $username = "root"; $password = ""; $database = "complain_system"; $con = mysqli_connect($server, $username, $password, $database) or die ("Could not connect: " . mysqli_connect_error()); $Title=$_POST["title"]; $Name=$_POST["name"]; $Message=$_POST["message"]; //storing file in filename variable $fileName = $_FILES['file']['name']; //This is the directory where images will be saved $target = "http://localhost:8000/ionic/"; $target = $target . strtolower( $_FILES['file']['name']); mkdir ($target, 0777, true); move_uploaded_file($_FILES['file']['tmp_name'],$target); $sql = "INSERT INTO photo (title,name,message,imgfile) "; $sql .= "VALUES ('$Title','$Name', '$Message', '".strtolower($_FILES['file']['name'])."')";//strlower new base file nam basename if($con->query($sql)){ echo "Your comment has been sent"; } else{ echo "Error in sending your comment"; } ?>