Upload an image take by the camera

Hello !
After a long day of research I can’t tranfer an image taken by my camera to my php API.
I tried some various tutorial (https://devdactic.com/ionic-2-images/) but I don’t reach my objective.

After that my code is so messy, so I clean it as well as possible. So do you have an idea to take a picture and to upload it on the server ?

Thanks you for your response.

    takePicture() {
        this.photo_link = '';
            quality: 100,
            sourceType: this.camera.PictureSourceType.CAMERA

        }).then((imagePath) => {
                this.image = imagePath;
            , (err) => {

    upload(id: number) {
        var api = "myapi"+id;
        const fileTransfer: TransferObject = this.transfer.create();
        let options: FileUploadOptions = {
            fileKey: 'photo',
            fileName: 'image.jpg',
            httpMethod: 'POST',
            chunkedMode: false,
            mimeType: "multipart/form-data",
        alert("push photo");
        fileTransfer.upload(this.image,api, options)
            .then((data) => {
            .catch((err) => {
                alert("error photo" + JSON.stringify(err));


Hello @zarnifoulette
have you find any solution, i am on same road.
can you give me some guideline or code.
i have also some extra parameters like name,email with image parameter, how did you managed to do that.


Hi @zarnifoulette
Could you try convert your image url to base64:

captureImage () {
  let options = {
    destinationType : Camera.DestinationType.DATA_URL,
    sourceType : Camera.PictureSourceType.PHOTOLIBRARY
  Camera.getPicture(options).then((imageData) => {
    // imageData is either a base64 encoded string or a file URI
    // If it's base64:
    this.base64Image = 'data:image/jpeg;base64,' + imageData;
    // Here ,  you pass bas64 image to your Api   
  }, (err) => {
    // Handle error

Hope,this will solve your issue