0

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

erdemgunenc
  • 969
  • 3
  • 14
  • 25
  • Your code to get the image name looks right. I think that you want to use Camera.DestinationType.FILE_URI as destinationType instead of Camera.DestinationType.DATA_URL. – Blauharley Oct 31 '16 at 19:51
  • Thank you so much @Blauharley it works now. – erdemgunenc Oct 31 '16 at 21:43
  • You are welcome :) – Blauharley Oct 31 '16 at 21:51
  • May i ask something else you @Blauharley you are good at this :) ,i cant upload my server this image {"code":1,"source":"file:\/\/\/storage\/emulated\/0\/android\/data\/com.erdem.xxxxx\/cache\/","target":"http:\/\/xxxx.xxxxx.: appname\/cache: open failed: EISDIR (Is a directory)"} E java.io.FileNotFoundException: /storage/emulated/0/android/data/com.erdem.xxxx/cache: open failed: EISDIR (Is a directory) – erdemgunenc Oct 31 '16 at 22:13
  • I hope I can help you on again. A process seems to open a file(image) that is not at the location where it is thought to be. So that's why there is a FileNotFoundException. I think it would be best to open another question to put relevant code into ;) – Blauharley Oct 31 '16 at 22:18
  • Thank you again @Blauharley .I will try more with what you said:) then if i cant figure out i will put a new question :) – erdemgunenc Oct 31 '16 at 22:20

0 Answers0