Am new to ionicFramework and Angularjs and have been able to set up my application with this controller to capture images with camera or from device photo gallery. But my problem is how to include the image caption in and input field then send php file in my server to handle the business logic:
$scope.takePhoto = function(){
var options = {
quality: 80,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 500,
targetHeight: 500,
popoverOptions: CameraPopoverOptions,
correctOrientation: true,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.srcImage = imageData;
}, function(err) {
// error
});
};
//Photo from gallery
$scope.selectPhoto = function(){
var options = {
quality: 80,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 500,
targetHeight: 500,
correctOrientation: true
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.srcImage = imageData;
}, function(err) {
// error
});
};
$scope.uploadPhoto = function(){
$scope.photoDetails = {};
$scope.photoDetails.desc = "";
var fileURL = $scope.srcImage;
var uploadOptions = new FileUploadOptions();
uploadOptions.fileKey = "file";
uploadOptions.fileName = fileURL.substr(fileURL.lastIndexOf('/') + 1);
uploadOptions.mimeType = "image/jpeg";
uploadOptions.chunkedMode = false;
$cordovaFile.uploadFile('www.mydomain.com/upload_user_photo.php', fileURL, uploadOptions).then(
function(result) {
// Success!
}, function(err) {
// Error
});
}
Please I need how to include caption input variable to my upoad and how to also get them in php file. Am I getting them with post or what?