When i try to upload a photo from library i able to select a photo from library…but when it time to upload it shows a run time error


here my code>{     
//toast controller  
   this.loading = this.loadingctrl.create({    
    content:'Please Wait..', 
   if('android') && sourceType ==={
         .then(filePath => {         
            let correctPath = filePath.substr(0, filePath.lastIndexOf('/') + 1);     
             let currentName = imagePath.substring(imagePath.lastIndexOf('/') + 1,  imagePath.lastIndexOf('?'));      
              is.copyFileToLocalDir(correctPath, currentName, this.createFileName());    
 } else {    
   var currentName = imagePath.substr(imagePath.lastIndexOf('/') + 1);    
   var correctPath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1); 
     this.copyFileToLocalDir(correctPath, currentName, this.createFileName());
    this.presentToast('Error while Selecting Image..!'); 

Anyhelp Thanks..:)
1 Like

So line #1 works.

What code using a Cordova plugin would be executed then? (I don’t really know as your code doesn’t explain itself) That plugin seems to be missing.

yeah line 1 works all fine …but when i select a picture and tap on okay to upload it shows this error…

camera ,File Plugin

for this work

Post your ionic cordova plugin list output please.

cordova-plugin-add-swift-support 1.6.0 "AddSwiftSupport"
cordova-plugin-battery-status 1.2.4 "Battery"
cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.7 "Console"
cordova-plugin-contacts 2.3.1 "Contacts"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-googleplus 5.1.1 "Google SignIn"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-media 3.0.1 "Media"
cordova-plugin-media-capture 1.4.3 "Capture"
cordova-plugin-nativestorage 2.2.2 "NativeStorage"
cordova-plugin-photo-library 2.0.4 "Photo Library"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-plugin-x-toast 2.6.0 "Toast"
ionic-plugin-keyboard 2.2.1 “Keyboard”

Please find out exactly which line is throwing that error and make sure the Ionic Native plugin and Cordova plugin behind it are installed.

okay i’ll try to find…:slight_smile:

Hi Madhi!
Have you found the solution?
I’m stuck w/ similar problem!


which part you facing this problem…whether uploading from library or taking pictures from camera?

1 Like


I got the problem in iOS env.

Either picking from library or taking pictures from the camera seems to work, at least in UI…

After taking picture or picking from library I get “plugin_not_installed”. I think the problem might be related to “cordova-plugin-file” or maybe “cordova-plugin-filepath” (which is android only).

Anyway I didn’t see “cordova-plugin-filepath” in your plugin list.

Here is mine.

cordova-plugin-camera 2.4.1 "Camera"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-contacts 2.3.1 "Contacts"
cordova-plugin-crop 0.3.1 "CropPlugin"
cordova-plugin-customurlscheme 4.3.0 "Custom URL scheme"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-filepath 1.0.2 "FilePath"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-google-analytics 1.8.2 "Google Universal Analytics Plugin"
cordova-plugin-network-information 1.3.3 "Network Information"
cordova-plugin-safariviewcontroller 1.4.7 "SafariViewController"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 1.10.4 “PushPlugin”

show your code…there is a problem in code

1 Like

Well, basically it is the same code as yours’
What was wrong in your code?

My code had error in Copyfiledirectory function i’ll paste my code here to solve your problem

selecting image from gallery code is below

     let options = {       
            quality: 50,   
      };       >{      
            let loader= this.loadingctrl.create({  
                  content: "Please Wait..Image is loading",
                    this.uploadedImage = "data:image/jpeg;base64," + data;
              alert("Failed to Load image.. :(")  
                 alert("Sorry doesnt enter into the plugin");    

to take pictures from camera code is below

       var options = { 
                 let load = this.loadingctrl.create({   
                      content: 'Please wait..While Image is loading',
             this.uploadedImage = 'data:image/jpeg;base64,' + imageData;   
            }, (error)=>{    
                      alert("Error Occured");     
1 Like

Ty Madhi…

So in order to do not rely on Copy Stuff, you do tried to get inline data from DestinationType.DATA_URL, I presume…

I think i still need DestinationType.FILE_URI in my case… :frowning:

Do you have any clue @Sujan12 ? bout a working snippet, for camera DestinationType.FILE_URI in Ionic3 iOS?

I’m still getting plugin_not_installed…


Well, nevermind.

I skipped copy phase somehow. Now everything started to work.


Do you have any idea of how I could do it with videos?