在将图像上传到服务器时,没有错误,并且吐司成功,但是没有图像保存在上传文件夹中

时间:2019-03-23 10:42:53

标签: ionic3

getImage() {
    const options: CameraOptions = {
      quality: 100,
      destinationType: this.camera.DestinationType.FILE_URI,
      sourceType: this.camera.PictureSourceType.PHOTOLIBRARY
    }

    this.camera.getPicture(options).then((imageData) => {
     this.imageURI = imageData;
      //this.targetPath = this.file.dataDirectory + imageData;
    }, (err) => {
      console.log(err);
      this.presentToast(err);
    });
  }

  uploadFile() {
    let loader = this.loadingCtrl.create({
      content: "Uploading..."
    });
    loader.present();
    const fileTransfer: FileTransferObject = this.transfer.create();

    let options: FileUploadOptions = {
      fileKey: 'ionicfile',
      fileName: 'ionicfile',
      chunkedMode: false,
      mimeType: "image/jpeg",
      headers: {}
    }

    fileTransfer.upload(this.imageURI, 'http://172.22.16.102/workproapi/imageupload.php', options)
      .then((data) => {
      console.log(data+" Uploaded Successfully");
     this.imageFileName = "http://172.22.16.102/static/images/ionicfile.jpg"
      loader.dismiss();
      this.presentToast("Image uploaded successfully");
    }, (err) => {
      console.log(err);
      loader.dismiss();
      this.presentToast(err);
    });
  }

0 个答案:

没有答案