Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70757

Ionic 4 can't upload image to server php

$
0
0

@sehsah2020 wrote:

hi ,
when i upload image with input text .
input text only send to database

code add.ts

  let postData = {
    "username": this.username,
    "fullname": this.fullname,
    "cat": this.cat,
    "country": this.country,
    "sex": this.sex,
    "image": this.imageData,
 } 
   let data:Observable<any> = this.http.post(this.url+/api/addsnap',postData );
   data.subscribe((res) => {
    console.log(res);
   });

code select

 takePicture(sourceType) {
    const options: CameraOptions = {
      quality: 50,
      sourceType: sourceType,
      destinationType: this.camera.DestinationType.FILE_URI,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
    }
    this.camera.getPicture(options).then((imageData) => {   
      this.imageData = 'data:image/jpeg;base64,' + imageData;
      this.correctPath = imageData.substr( imageData.lastIndexOf('/') + 1);
      console.log("imageData"+this.correctPath);
        }, (err) => {
        // Handle error
    });

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70757

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>