I'm trying to get a file attached via a button. The problem is that the file arrives but is not set up, as shown in the screenshots below, just below the images has the method and html of the button.
docFile(event: any) {
let reader = new FileReader();
let size = event.target.files[0].size;
if (event.target.files && event.target.files.length > 0) {
let file = event.target.files[0];
if (size > 2097152) {
this.template.openModal()
} else {
reader.readAsDataURL(file);
reader.onload = (event: any) => {
this.imagemDoc = event.target.result;
console.log(size);
this.dadosPessoaisForm.get('documentos.arquivo').setValue({
id: this.arquivo.id,
nome: file.name,
tipo: file.type,
// dados: reader.result.split(',')[1]
})
};
}
}
}
<div class="input-group-addon" style="background-color: #ffffff">
<div class="upload-btn-wrapper">
<button type="file" class="fa fa-paperclip"></button>
<input type="file" class="btn btn-default" id="arquivo" accept='file/*' (change)="docFile($event)" #fileInput>
</div>
</div>