嗨,我有一个离子开发和工作很棒的前端,但我不知道如何发送这张照片到后端。JSON Objetc?字符串?base64?如何将输入文件转换为base64?考虑到这个pwa和cordova不起作用。
在我的html上有这个
<div class="btn">
<label>
<ion-icon slot="start" name="camera"></ion-icon>
Sucursal de Instalación
<input type="file" style="display: none;" (change)="subirInstalacion($event)">
</label>
</div>在我的房间里,我有这个
subirInstalacion(fileInput: any) {
//trae imagen de la galeria
this.fileData = <File>fileInput.target.files[0];
this.preview();
}
preview() {
// vista previa de la imagen
var mimeType = this.fileData.type;
if (mimeType.match(/image\/*/) == null) {
return;
}
let reader = new FileReader();
reader.readAsDataURL(this.fileData);
reader.onload = (_event) => {
this.previewSucursalInstalacion = reader.result;
}
}谢谢,
发布于 2019-10-11 13:20:59
这取决于您想使用哪种类型的后端。
你要么需要设置你自己的服务器和web,比如this或者this。然而,它将需要更多的代码才能在现实世界中用于安全等。
或者,您可以将其放入云中。有很多服务可以托管图像。
Firebase是一个很受欢迎的工具。还有一个有趣的名字叫Uploadсare。有一个系列教程that combines these two technologies。
https://stackoverflow.com/questions/58327087
复制相似问题