0
I wonder how I can be sending an image to an api at Angular 6 through the post method.
First I must encode this image in base 64 and then I send all that coding as a key value????
0
I wonder how I can be sending an image to an api at Angular 6 through the post method.
First I must encode this image in base 64 and then I send all that coding as a key value????
1
At Angular 6, you can send the image bits in the body of the POST request.
sendImage(imagem) {
return this.httpClient.post(URL, imagem, {headers: this.headers});
}
And then the server would process the image bits and store the file in memory. You can use the same logic with the PUT request.
Sending through a GET request culminates in placing image bits in the request header.
Browser other questions tagged angular post image
You are not signed in. Login or sign up in order to post.
What do you mean by sending the image bits? is via base 64 encoding?
– veroneseComS
Yes. If you use a type input
file
, you can associate a function to the event change(change)="funcao()"
, and every time the input value is changed, it performs this function.– mutlei