@Haug wrote:
Hello everybody
I’m almost about to give up because I struggle with this issue for almost a week.
I tried very hard and really checked most of all the tutorials in the web concerning the theme of uploading a file (img) within Ionic 3 to a server using php. Within iOS I get the message (code 200) that everything is fine but the image is not shown on the server. I almost checked about ten solutions - but none of them worked. What do I do wrong?
I checked my php already with a simple webpage. From there upload of files works without any problems.
If anyone has a working example I would be very greatfull if this would be shared. I would even pay for that solution because I want to have the issue fixed.
Can any body help?
thank you very much in advance for your help.
Cheers
My Code looks as follows,
public getImage() {
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.FILE_URI,
encodingType: this.camera.EncodingType.JPEG,
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
}this.camera.getPicture(options).then((imageData) => { this.testpic = imageData; this.imageURI = normalizeURL(imageData); imageData = normalizeURL(imageData); this.uploadimage = imageData; this.lastImage = '..'; }, (err) => { console.log(err); this.presentToast(err); }); } public uploadImage() { const fileTransfer: FileTransferObject = this.transfer.create(); let loader = this.loadingCtrl.create({ content: "Uploading..." }); loader.present(); this.imageURI = this.uploadimage; alert(this.testpic); console.log('TestPic ' + this.testpic); let options: FileUploadOptions = { fileKey: 'file', fileName: this.testpic.substr(this.testpic.lastIndexOf('/')+1), chunkedMode: false, mimeType: "image/jpeg", headers: {} } fileTransfer.upload(this.testpic, 'http://localhost:8888/uplaod.php', options) .then((data) => { console.log(data+" Uploaded Successfully"); loader.dismiss(); this.presentToast("Image uploaded successfully"); }, (err) => { console.log(err); loader.dismiss(); this.presentToast(err); }) loader.dismiss(); }
My environment:
Ionic:
ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.1.4, (and 12 other plugins)System:
ios-deploy : 1.9.2
ios-sim : 5.0.12
NodeJS : v7.0.0 (/usr/local/bin/node)
npm : 5.6.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Posts: 1
Participants: 1