Does anyone know how to send picture (file) as a part of form data using AuthHttp (angular2-jwt) service in Angular 2?
Asked
Active
Viewed 791 times
2 Answers
0
you can create object of that file information and send over http request
Like:
var formData = new FormData(document.getElementById("formName"));
for(var i=0;i<obj.length;i++){
formData.append("file["+i+"]",obj.fileModel[i]);
}
formData.append("title",title);
formData.append("xyz",xyz);
And send this formData to http request

Amee Prajapati
- 696
- 4
- 10
0
Sending a file using authHttp can be done like this:
let file = new File([blobData], "filename.png");
const url = 'https://example.com/upload';
let formData:FormData = new FormData();
formData.append('file', file, file.name);
this.authHttp.put(url, formData)
.catch(this.handleError);

Tom
- 874
- 7
- 13