# Upload multiple file to the server

**URL:** <https://forum.ionicframework.com/t/upload-multiple-file-to-the-server/94422>\
**Category:** ionic-v3\
**Created:** [June 15, 2017, 6:10am UTC](https://forum.ionicframework.com/t/upload-multiple-file-to-the-server/94422 "2017-06-15T06:10:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe\_c\_sleiman](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@joe\_c\_sleiman](https://forum.ionicframework.com/u/joe_c_sleiman)\
**Post date:** [June 15, 2017, 6:10am UTC](https://forum.ionicframework.com/t/upload-multiple-file-to-the-server/94422/1 "2017-06-15T06:10:40Z")

</div>

hi i want to upload multiple file and send them to a server: using reactive form

```auto
this.attachmentsForm = this.formBuilder.group({
        attachmentName: ['']
 });

```

```auto
 <form [formGroup]="attachmentsForm">
          <ion-item>
            <ion-label floating>
              Attachment Name
            </ion-label>
            <ion-input type="text" formControlName="attachmentName"></ion-input>
          </ion-item>
          <input class="form-control" #fileInput type='file' (change)="fileChanged($event)">
        </form>

```

```auto
 fileChanged(event) {
    if (event.target.files && event.target.files[0]) {
      if (event.target.files[0].size > 512000) {
        this.fileValid = false;
        let toast = this.toastCtrl.create({
          message: 'the file size more than 500kb',
          duration: 3000
        });
        toast.present();
      } else {
        this.fileValid = true;
      }
    }

  }

```

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [June 15, 2017, 10:21pm UTC](https://forum.ionicframework.com/t/upload-multiple-file-to-the-server/94422/2 "2017-06-15T22:21:28Z")

</div>

How to go about this totally depends on what format the server is expecting.

---

<div class="post-metadata">

**Author:** ![joe\_c\_sleiman](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@joe\_c\_sleiman](https://forum.ionicframework.com/u/joe_c_sleiman)\
**Post date:** [June 16, 2017, 12:15pm UTC](https://forum.ionicframework.com/t/upload-multiple-file-to-the-server/94422/3 "2017-06-16T12:15:52Z")

</div>

thanks @rapropos i solve it for one image , i change the behaviour for each image a button ,  
but it may later need multiple image in the same add button ,

```auto
fileChanged(event) {
    let reader = new FileReader();
    let file = event.target.files;
    if (file[0].size > 1000000) {
      this.fileValid = false;
      let toast = this.toastCtrl.create({
        message: 'the file size more than 1MB',
        duration: 3000
      });
      toast.present();
    } else {
      reader.onloadend = () => {
          this.fileValid = true;
      }
      reader.readAsDataURL(file[0]);
    }
  }

```
