In my application that i am developing in Angular 4, user can upload multipart files into server. Files are large. I need to show the current progress of file upload process with it's percentage to user, how can i do it?
Thanks in advance!
In my application that i am developing in Angular 4, user can upload multipart files into server. Files are large. I need to show the current progress of file upload process with it's percentage to user, how can i do it?
Thanks in advance!
use angular-loading-bar library, if you don't want to use angular-loading-bar library you can use progress callback eq-xhrrequest.upload.onprogress.
You can easily achieve this with:
npm i angular-progress-http
After importing the module, you can now add below it to your app.module.ts or wherever you stack your app modules in your application.
You will import this (in app.module.ts):
Still in your app.module.ts
at @NgModule
Then in your component file (whatever.component.ts), where you want to use it. You can place this:
Then implement like this:
Since you are using Angular4 , it can be achieved using
Listening to progress
events using the new HttpClient from@angular/common/http.
Adding code from the docs,
and then,
EDIT Since OP wanted to use it with angular2, should use native JavaScript XHR wrapped as an Observable as mentioned in this
answer
Gajender.service.ts
user.component.ts
user.component.html