File Upload With Progress Bar In Angular 13

Websolutionstuff | Jun-11-2022 | Categories : Bootstrap Angular

In this article, we will see the file upload with a progress bar in angular 13. In this example, we will learn how to image upload with the progress bar in angular 13. we will create a simple reactive form with image upload. Also, create a PHP API for image upload. in API service we will write code for showing progress bar percentage code.

So, let's see file upload with progress bar in angular 13, angular 13 image upload, angular 13 file upload with progress bar, file upload in angular 12/13, angular file upload with progress bar, multiple file upload in angular 12/13, image upload in angular 13, angular 13 image upload with progress bar, upload progress bar angular.

Step 1: Create New App

In this step, we will create a new app using the below command.

ng new my-new-app



Step 2: Install Bootstrap 5

Now, we will install the bootstrap core package using the below command.

npm install bootstrap --save

Now, we need to include bootstrap CSS like node_modules/bootstrap/dist/css/bootstrap.min.css. So, add it to the angular.json file.


"styles": [





Step 3: Import Module

Now, we will import HttpClientModule, ReactiveFormsModule, and ImageUploadService to the app.module.ts file.


import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";

import { AppComponent } from "./app.component";

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



Step 4: Updated View File

In this step, we will update the HTML file.


<h2>File Upload With Progress Bar In Angular 13 - Websolutionstuff</h2>
<input type="file" (change)="upload($[0])">

<div class="progress" *ngIf="progress">
	<div class="progress-bar" [style.width]="progress + '%'">{{progress}}%</div>


Step 5: Use Component ts File

Now, we need to update our component.ts file.


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

import {
} from "@angular/common/http";

import { map, catchError } from "rxjs/operators";

import { throwError } from "rxjs";

  selector: "my-app",
  templateUrl: "./app.component.html",
  styleUrls: ["./app.component.css"]
export class AppComponent {
  progress: number;

  constructor(private http: HttpClient) {}

  upload(file) {
    this.progress = 1;
    const formData = new FormData();
    formData.append("file", file);

      .post("your-url-here", formData, {
        reportProgress: true,
        observe: "events"
        map((event: any) => {
          if (event.type == HttpEventType.UploadProgress) {
            this.progress = Math.round((100 / * event.loaded);
          } else if (event.type == HttpEventType.Response) {
            this.progress = null;
        catchError((err: any) => {
          this.progress = null;
          return throwError(err.message);



Step 6: Run The Server

In last, we need to run the server using the below command.

ng serve

Now, Go to your web browser, type the given URL and view the app output.






You might also like:

Recommended Post
Featured Post
How To Hide Toolbar In Summernote Editor
How To Hide Toolbar In Summern...

In this small tutorial i will show you How To Hide Toolbar In Summernote Editor, many times customer's have req...

Read More


Laravel 11 Livewire Form Validation Example
Laravel 11 Livewire Form Valid...

Hello, laravel web developers! In this article, we'll see how to validate forms in laravel 11 Livewire. In lara...

Read More


How To File Upload In Laravel 10 Example
How To File Upload In Laravel...

In this article, we will see how to file upload in laravel 10 examples. Here, we will learn about the laravel...

Read More


Laravel 8 Toastr Notifications Example
Laravel 8 Toastr Notifications...

Today, I will show you Laravel 8 Toastr Notifications Example. There are many types of notifications availa...

Read More