Codova file transfer send wrong mimetype

Hi,

When I upload a .png photo from my album with cordova file transfer plugin, my php script says I uploaded a jpg. But it’s wrong it’s a .png. With a .jpg of course no problem, everything works fine.

And this is a real problem, because my web site only accepts jpg. So I need to send the right mimetype or get the mimetype before transfer the file so I can display an error.

If someone can help me :slight_smile:

Here’s my code :

    $scope.takePic = function() {
        var deferred = $q.defer();
        var hideSheet = $ionicActionSheet.show({
            buttons: [
                { text: 'Via camera' },
                { text: 'Via photo album' }
            ],
            titleText: 'Add piecture :',
            cancelText: 'Cancel',
            cancel: function() {
                deferred.reject();
            },
            buttonClicked: function(index) {
                $ionicLoading.show({
                    template: '<ion-spinner icon="android"></ion-spinner>'
                });
                deferred.resolve(index);
            return true;
            }
        });
        var options = {
            destinationType: Camera.DestinationType.FILE_URI,
            correctOrientation: true,
            //allowEdit : true,
            quality: 75,
            encodingType: Camera.EncodingType.JPEG,
            targetWidth: 720
        };

        deferred.promise.then(function(index) {
            if(index == 0) {
                options.sourceType = Camera.PictureSourceType.CAMERA;
            } else {
                options.sourceType = Camera.PictureSourceType.PHOTOLIBRARY;
            }
            return $cordovaCamera.getPicture(options);
        }).then(function(imageURI) {
            var options = {
                params: {
                    "headers": {
                        'Authorization': 'Bearer ' + $rootScope.bearer
                    }
                }
            };
            //alert(imageURI);
            return $cordovaFileTransfer.upload('http://.......', imageURI, options);
        }).then(function(result) {
            $ionicLoading.hide();
            var json = result.response;
            var obj = JSON.parse(json);

            $scope.progress = 'SUCCESS!';
        }, function(err) {
            $ionicLoading.hide();
            $scope.progress = 'FAIL!';
        }, function (progress) {
            $scope.progress = progress;
        });
    }

thx