Angular 11 Multiple Files upload example with Progress Bar

In this tutorial, I will show you way to build Multiple Files upload example using Angular 11, Bootstrap and FormData with Progress Bars.

More Practice:
Angular 11 (single) File upload example with progress bar
Angular 11 CRUD Application example with Web API
Angular 11 JWT Authentication example with Web Api
Angular 11 Form Validation example (Reactive Forms)

Newer versions:
Angular 12 Multiple Files upload example
Angular 13 Multiple Files upload example
Angular 14 Multiple Files upload example
Angular 15 Multiple Files upload example
Angular 16 Multiple Files upload example
Angular 17 Multiple Files upload example


We will create an Angular 11 Multiple Files upload application in that user can:

  • see the upload process (percentage) of all uploading files
  • see the notification message of each file upload status
  • view all uploaded files
  • download file by clicking on the file name


If one of the upload progress is not successful:


If you want to upload image with Preview:


Please visit:
Angular 11 Multiple Images Upload with Preview example


  • Angular 11
  • RxJS 6
  • Bootstrap 4

Web API for File Upload & Storage

Here is the API that our Angular App will work with:

Methods Urls Actions
POST /upload upload a File
GET /files get List of Files (name & url)
GET /files/[filename] download a File

You can find how to implement the Rest APIs Server at one of following posts:
Node.js Express File Upload Rest API example
Node.js Express File Upload to MongoDB example
Node.js Express File Upload to Google Cloud Storage example
Spring Boot Multipart File upload (to static folder) example

Setup Angular 11 Project

Let’s open cmd and use Angular CLI to create a new Angular Project as following command:

ng new Angular11MultipleFilesUpload
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS

We also need to generate some Components and Services:

ng g s services/upload-files  
ng g c components/upload-files

Now you can see that our project directory structure looks like this.

Angular 11 App for upload multiple Files


Let me explain it briefly.

– We import necessary library, components in app.module.ts.
upload-files.service provides methods to save File and get Files from Rest Apis Server.
upload-files.component contains upload multiple files form, some progress bars, display of list files.
app.component is the container that we embed all components.
index.html for importing the Bootstrap.

Set up App Module

Open app.module.ts and import HttpClientModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { HttpClientModule } from '@angular/common/http';
import { UploadFilesComponent } from './components/upload-files/upload-files.component';

  declarations: [
  imports: [
  providers: [],
  bootstrap: [AppComponent]
export class AppModule { }

Add Bootstrap to the project

Open index.html and add following line into <head> tag:

<!DOCTYPE html>
<html lang="en">
    <link type="text/css" rel="stylesheet" href="" />

Create Angular Service for Upload Multiple Files

This service will use Angular HTTPClient to send HTTP requests.
There are 2 functions:

  • upload(file): returns Observable<HttpEvent<any>> that we’re gonna use for tracking progress
  • getFiles(): returns a list of Files’ information as Observable object


import { Injectable } from '@angular/core';
import { HttpClient, HttpRequest, HttpEvent } from '@angular/common/http';
import { Observable } from 'rxjs';

  providedIn: 'root'
export class UploadFilesService {
  private baseUrl = 'http://localhost:8080';

  constructor(private http: HttpClient) { }

  upload(file: File): Observable<HttpEvent<any>> {
    const formData: FormData = new FormData();

    formData.append('file', file);

    const req = new HttpRequest('POST', `${this.baseUrl}/upload`, formData, {
      reportProgress: true,
      responseType: 'json'

    return this.http.request(req);

  getFiles(): Observable<any> {
    return this.http.get(`${this.baseUrl}/files`);

FormData is a data structure that can be used to store key-value pairs. We use it to build an object which corresponds to an HTML form with append() method.

– We set reportProgress: true to exposes progress events. Notice that this progress event are expensive (change detection for each event), so you should only use when you want to monitor it.

– We call the request(PostRequest) & get() method of HttpClient to send an HTTP POST & Get request to the Multiple Files Upload Rest server.

Create Angular Component for Upload Multiple Files

Let’s create a Multiple Files Upload UI with Progress Bars, Card, Button and Message.

First we need to use the following imports:


import { Component, OnInit } from '@angular/core';

import { HttpEventType, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';
import { UploadFilesService } from 'src/app/services/upload-files.service';

Then we define the some variables and inject UploadFilesService as follows:

export class UploadFilesComponent implements OnInit {

  selectedFiles?: FileList;
  progressInfos: any[] = [];
  message: string[] = [];

  fileInfos?: Observable<any>;

  constructor(private uploadService: UploadFilesService) { }


The progressInfos is an array that contains items for display upload progress of each files. Each item will have 2 fields: value & fileName.

Next we define selectFiles() method. It helps us to get the selected Files that we’re gonna upload.

selectFiles(event): void {
  this.message = [];
  this.progressInfos = [];
  this.selectedFiles =;

Now we iterate over the selected Files above and call upload() method on each file item.

uploadFiles(): void {
  this.message = [];

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

Next we define upload() method for uploading each file:

upload(idx: number, file: File): void {
  this.progressInfos[idx] = { value: 0, fileName: };

  if (file) {
      (event: any) => {
        if (event.type === HttpEventType.UploadProgress) {
          this.progressInfos[idx].value = Math.round(100 * event.loaded /;
        } else if (event instanceof HttpResponse) {
          const msg = 'Uploaded the file successfully: ' +;
          this.fileInfos = this.uploadService.getFiles();
      (err: any) => {
        this.progressInfos[idx].value = 0;
        const msg = 'Could not upload the file: ' +;
        this.fileInfos = this.uploadService.getFiles();

We use idx for accessing index of the current File to work with progressInfos array. Then we call uploadService.upload() method on the file.

The progress will be calculated basing on event.loaded and
If the transmission is done, the event will be a HttpResponse object. At this time, we call uploadService.getFiles() to get the files' information and assign the result to fileInfos variable.

We also need to do this work in ngOnInit() method:

ngOnInit(): void {
  this.fileInfos = this.uploadService.getFiles();

Now we create the HTML template of the Upload multiple Files UI.
Add the following content to upload-files.component.html file:

<div class="row">
  <div class="col-8">
    <label class="btn btn-default p-0">
      <input type="file" multiple (change)="selectFiles($event)" />

  <div class="col-4">
      class="btn btn-success btn-sm"

<div *ngFor="let progressInfo of progressInfos" class="mb-2">
  <span>{{ progressInfo.fileName }}</span>
  <div class="progress">
      class="progress-bar progress-bar-info progress-bar-striped"
      attr.aria-valuenow="{{ progressInfo.value }}"
      [ngStyle]="{ width: progressInfo.value + '%' }"
      {{ progressInfo.value }}%

<div *ngIf="message.length" class="alert alert-secondary my-3" role="alert">
  <ul *ngFor="let msg of message; let i = index">
    <li>{{ msg }}</li>

<div class="card mt-3">
  <div class="card-header">List of Files</div>
    class="list-group list-group-flush"
    *ngFor="let file of fileInfos | async"
    <li class="list-group-item">
      <a href="{{ file.url }}">{{ }}</a>

Add Upload Multiple Files Component to App Component

Open app.component.html and embed the UploadFile Component with <app-upload-files> tag.

<div class="container" style="width:600px">
  <div class="my-3">
    <h4>{{ title }}</h4>



import { Component } from '@angular/core';

  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
export class AppComponent {
  title = 'Angular 11 Multiple Files Upload';

Run the App

If you use Spring Boot Server above, run it with command: mvn spring-boot:run.
Refresh the project directory and you will see uploads folder inside it.

Because we configure CORS for origin: http://localhost:8081, so you need to run Angular 11 Client with command:
ng serve --port 8081

Open Browser with url http://localhost:8081/ and check the result.

Further Reading


Today we're learned how to build an example for multiple Files upload using Angular 11 and FormData. We also provide the ability to show list of files, multiple progress bars using Bootstrap.

You can find how to implement the Rest APIs Server at one of following posts:
- Node.js Express File Upload Rest API example
- Node.js Express File Upload to MongoDB example
- Node.js Express File Upload to Google Cloud Storage example
- Spring Boot Multipart File upload (to static folder) example

If you want to upload image with Preview:


Please visit:
Angular 11 Multiple Images Upload with Preview example

Source Code

The source code for this Angular 11 Client is uploaded to Github.

4 thoughts to “Angular 11 Multiple Files upload example with Progress Bar”

  1. Hello.
    Thank you for your lessons on spring security and angular.
    However, is it possible that you add an otp code during the registration of a user and that the latter must validate his account with a generated otp code which will also activate his account and be able to connect.
    Thank you in advance.

Comments are closed to reduce spam. If you have any question, please send me an email.