Search code examples
angularc#-4.0epplus-4

How to send uploaded excel file to C# Post API using Angular 4


var fd = new FormData();
fd.append('file', data.target.files[0]);
return this.http.post(url), fd).map().catch();

Using AngularJS it's working but for angular 4 when i used the same way it's not working.I am getting disk error while uploading excel file.Please help me.


Solution

  • In service

    public importMassUpdateExcel(file: FormData, id): Observable<any> { const headers = new Headers({ 'Authorization': '',//authorization token 'Content-Type': 'application/json; charset=UTF-8'// }); const options = new RequestOptions({ headers: headers }); return this.http .post(url, file, options) .map() .catch(); }