Cordova get image name

631 Views Asked by At

I research lots of article but i coudlnt figure out.I want to upload image with taking photo but cant get the exact name of image to take it from phone.

 $scope.takePicture = function () {
    var options = {
      destinationType: Camera.DestinationType.DATA_URL,
      encodingType: Camera.EncodingType.JPEG
    }
    $cordovaCamera.getPicture(options)
      .then(function (data) {

        var options2 = new FileUploadOptions();
        options2.fileName = data.substr(data.lastIndexOf('/') + 1);

        console.log("options: " + JSON.stringify(data));

        $scope.pictureUrl = 'data:image/jpeg;base64,' + data;
      }, function (err) {

      })

this data returns 9j,4AAQSkZJRgABAQAAAQABAAD, and goes like it, then i figure out data.substr(data.lastIndexOf('/') + 1); takes 9 and add + 1 to J and give the fileName: 9k. Thank you

0

There are 0 best solutions below