I have a requirement where I need to convert the selected image (a part of a form group) to a byte array which needs to be sent as a part of a post request to the backend.
HTML Component:
<div class="form-group">
<label>Image</label>
<input type="file" accept="image/*" class="form-control" formControlName="productImage" onchange="displaySelectedImageFunc(this);">
<img *ngIf="displaySelectedImage" src="{{selectedImageUrl}}">
<span class="error-message" *ngIf="itemRegistrationForm.controls.productImage.dirty && itemRegistrationForm.controls.productImage.errors">Select Image of the product</span>
</div>