I am successfully in uploading image from gallery.But I am struck while uploading images
this is my code
pictureUpload(x){ // x is file:///storage/emulated/0/Download/palakkeni.jpg
if(this.network.noConnection()){
this.network.showNetworkAlert()
}else{
let loading = this.loadingCtrl.create({
spinner: 'bubbles',
content: 'Uploading your Picture...'
});
loading.present();
var fileArray = x.split("/");
let len = fileArray.length;
var file = fileArray[len - 1];
let fileTransfer: FileTransferObject = this.transfer.create();;
let option: FileUploadOptions = {
fileKey: 'img',
fileName: x,
mimeType: "multipart/form-data",
headers: {
authorization : 'e36051cb8ca82ee0Lolzippu123456*='
},
params: {
name: file,
id: this.empid
}
}
this.completed = false;
fileTransfer.upload(x, encodeURI("http://forehotels.com:3000/api/upload_employee_image"), option, true)
.then((data) => {
this.completed=true;
loading.dismiss()
console.log("image uploaded")
}, (err) => {
loading.dismiss()
console.log(err)
let alert = this.alertCtrl.create({
title: err.text(),
subTitle: err.json(),
buttons: ['Dismiss'],
});
alert.present();
});
this.view_picture = file;
this.picture=x
this.uploaded++
}
}
The following is my error output
FileTransferError
body: null
code: 3
exception: "Permission denied (missing INTERNET permission?)"
http_status: null
source: "file:///storage/emulated/0/Download/xyz.jpg"
target: "http://companydomainname.com:3000/api/upload_employee_image"
The following is my output of ionic info
Ionic:
Ionic CLI : 5.1.0 (C:\Users\pramo\AppData\Roaming\npm\node_modules\ionic) Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : android 8.0.0, browser 5.0.4 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 18 other plugins)
Utility:
cordova-res : 0.4.0 native-run : 0.2.6
System:
NodeJS : v10.15.3 (C:\Program Files\nodejs\node.exe) npm : 6.4.1 OS : Windows 10
My cordova plugins are
cordova-android-support-gradle-release 3.0.0 "cordova-android-support-gradle-release"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-calendar 5.1.0 "Calendar"
cordova-plugin-contacts 3.0.1 "Contacts"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-filechooser 1.0.1 "File Chooser"
cordova-plugin-filepath 1.0.2 "FilePath"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googleplus 5.3.0 "Google SignIn"
cordova-plugin-headercolor 1.0 "HeaderColor"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.1.2 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-nativestorage 2.3.1 "NativeStorage"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-plugin-x-socialsharing 5.4.0 "SocialSharing"
cordova-plugin-x-toast 2.6.2 "Toast"
cordova.plugins.diagnostic 4.0.7 "Diagnostic"
es6-promise-plugin 4.1.0 "Promise"
Can somebody please guide me as to why I am getting this error and hopefully solve it ?