I have created a form in ionic 2 where I have a field to upload resume which will be of type .docs or .pdf. I tried by adding as below.
<form [formGroup]="myForm">
<ion-list>
<ion-item>
<input type="file" formControlName="upresume_one" name="upresume_one"/>
<p>Supported formats .doc,.docs and .pdf[Max file size: 500KB]</p>
</ion-item>
<div class="text-right">
<button ion-button style="background-color: #16a085;color: white;" color="secondary" (click)="save(myForm.value)">Submit</button>
</div>
</ion-list>
</form>
My .ts file is as below:
myForm: FormGroup;
private myData: any;
constructor(public navCtrl: NavController,
public navParams: NavParams,
private builder: FormBuilder,
private userProfileService: UserProfileService,
private progressDialog: ProgressDialog) {
this.myForm = builder.group({
'upresume_one': ['', Validators.required]
})
on for submission I’m calling save function which is as below,
save(formData) {
console.log('Form data is ', formData);
}
In consoel.log I’m getting null even after valid files is being selected. Can some one please suggest me what is the best way to integrate input type file inside form in ionic 2.