我有一个要求,需要将所选图像(表单组的一部分)转换为字节数组,该数组需要作为发布请求的一部分发送到后端。
HTML 组件:
<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>
Run Code Online (Sandbox Code Playgroud) 我从 api 获取字节数组,并且在我的 HTML 页面上应用了图像标签 <img src="data:{{model.asd_logo_type}};base64,{{model.dfgh_logo}}" alt="...">
但我无法显示图像。
请建议我能做什么。