Skip to content Skip to sidebar Skip to footer

Ionic Cordova Fileupload Error: Not Allowed To Load Local Resource

I am new to Ionic and I am trying to upload an image taken from camera that is stored in Android filesystem: var ft = new FileTransfer(); console.log('Uploading: ' + fileURL); ft.u

Solution 1:

This happens when you use the "livereload" option with Ionic.

Try running in normal mode

Solution 2:

Another possible reason is that you have a webview plugin installed (like https://github.com/ionic-team/cordova-plugin-ionic-webview or just https://github.com/apache/cordova-plugin-wkwebview-engine). Also this will not allow to use cdvfile:// protocol as well.

Solution 3:

With ionic webview >3.x, you have to use convertFileSrc() method. For example if you have a myURL local variable such as file:// or /storage.

letwin: any = window; // hack ionic/angular compilatorvar myURL = win.Ionic.WebView.convertFileSrc(myURL);

Solution 4:

It might be too late but... you could convert native path to blob using File then convert blob to URL using URL.createObjectURL(blob) and passing/setting as src to your html element. This is unnecessary for production environment but you could use it for development with -lc. It might work

Solution 5:

07-Dec-2018

This is the version where it works for me on Ionic 3.9.2 app.

Remove the latest version of webview and then:

i.e. ionic cordova plugin add cordova-plugin-ionic-webview@1.2.1

https://github.com/ionic-team/cordova-plugin-ionic-webview/releases/tag/v1.2.1

Note: This version works fine with normalizeURL() method.

Post a Comment for "Ionic Cordova Fileupload Error: Not Allowed To Load Local Resource"