Angular: Upload fixed number of files to server

I want to upload 3 files each from it’s own input.

<label class="btn btn-default p-0">
            <input type="file" (change)="selectISRFile($event)" />
          </label>
          <label class="btn btn-default p-0">
            <input type="file" (change)="selectLMPFile($event)" />
          </label>
          <label class="btn btn-default p-0">
            <input type="file" (change)="selectPOCMRFile($event)" />
          </label>
<button
            class="btn btn-success btn-sm"
            (click)="uploadFiles()"
          >
            Upload
          </button>

Component functions looks like this

  selectISRFile(event): void {
    this.selectedFiles[0]= event.target.files;
  }

  selectLMPFile(event): void {
    this.selectedFiles[1] = event.target.files;
  }

  selectPOCMRFile(event): void {
    this.selectedFiles[2] = event.target.files;
  }

  uploadFiles() {
    if (this.selectedFiles) {
      for (let i = 0; i < this.selectedFiles.length; i++) {
        this.upload(i, this.selectedFiles[i]);
      }
    }
  }

I’m getting selectedFiles is undefined

  companyForm: FormGroup;
  selectedFiles?: FileList;
  progressInfos: any[] = [];
  message: string[] = [];
  selectedISRFile?: File;
  selectedLMPFile?: File;
  selectedPOCMRFile?: File;

thank you for your time

90 thoughts on “Angular: Upload fixed number of files to server”

  1. Pingback: stromectol mk
  2. Pingback: hydroxychloroquine
  3. Pingback: what is ivermectin
  4. Pingback: super viagra plus
  5. We’re a bunch of volunteers and opening a
    brand new scheme in our community. Your site provided us with helpful information to work on. You have done a formidable activity and our whole neighborhood
    can be grateful to you.

    Reply
  6. Fantastic goods from you, man. I’ve understand your stuff previous to and you are just
    extremely wonderful. I really like what you have acquired here, really
    like what you are saying and the way in which you say it.
    You make it enjoyable and you still care for to keep it sensible.
    I can’t wait to read much more from you. This is really a tremendous site.

    Reply
  7. I was curious if you ever thought of changing the structure of your blog?
    Its very well written; I love what youve
    got to say. But maybe you could a little more in the way of content so
    people could connect with it better. Youve got an awful lot of text for
    only having 1 or two pictures. Maybe you could space it out better?

    Reply
  8. Great work! This is the type of info that are meant to be shared around the internet.

    Disgrace on the search engines for now not positioning this post higher!
    Come on over and talk over with my site .
    Thanks =)

    Reply

Leave a Comment