Search code examples
cordova-pluginsionic4ionic-native

How to upload file from phone and send it as FormData Ionic 4


I'm using Ionic trying to use chooser plugin to chose file from phone, transform the URI to a File and send it as FormData. Nothing seems to work.


Solution

  • You can initialize FormData object by creating an instance from new FormData interface as given below. const formData = new FormData()

        const formData = new FormData();
        formData.append('firstname', this.firstname);
        formData.append('lastname', this.lastname);
        formData.append('email' , this.email);
        formData.append('phone' , this.phone);
        formData.append('experience' , this.experience);
        formData.append('userId' , this.userInfo.user.id);