# Problem with file Upload to server via php

**URL:** <https://forum.ionicframework.com/t/problem-with-file-upload-to-server-via-php/144484>\
**Category:** Ionic Native\
**Created:** [October 13, 2018, 10:57pm UTC](https://forum.ionicframework.com/t/problem-with-file-upload-to-server-via-php/144484 "2018-10-13T22:57:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haug](https://avatars.discourse-cdn.com/v4/letter/h/97f17d/32.png) [@Haug](https://forum.ionicframework.com/u/Haug)\
**Post date:** [October 13, 2018, 10:57pm UTC](https://forum.ionicframework.com/t/problem-with-file-upload-to-server-via-php/144484/1 "2018-10-13T22:57:27Z")

</div>

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.0

Cordova:

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

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:13pm UTC](https://forum.ionicframework.com/t/problem-with-file-upload-to-server-via-php/144484/2 "2021-07-19T21:13:22Z")

</div>


