1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
.controller('CameraCtrl', function($scope, Camera) {
$scope.getPhoto = function() {
Camera.getPicture().then(function (imageURI) {
// Show picture
$scope.lastPhoto = imageURI;
// Define FileTransfer vars and options
var ft = new FileTransfer(),
options = new FileUploadOptions();
options.fileKey = 'file';
options.fileName = imageURI.substr(imageURI.lastIndexOf('/')+1);
options.mimeType = 'image/jpeg';
options.chunkedMode = false;
options.params = {
"description": "uploaded from mobile"
};
// Upload the picture
ft.upload(imageURI, encodeURI("http://my-domain.com/upload.php"),
function(e) {
alert('picture was upload successfully');
},
function(e) {
alert('Error on upload: ' + JSON.stringify(e));
},
options,
true
);
ft.abort();
}, function (e) {
alert('oops, something was wrong: ' + e);
}, {
quality: 50,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
});
}
}); |
Partager