“upload de arquivo no angular 10” Respostas de código

Carregar arquivos com angular

fileChange(element) {
  this.uploadedFiles = element.target.files;
}

upload() {
  let formData = new FormData();
  for (var i = 0; i < this.uploadedFiles.length; i++) {
    formData.append("uploads[]", this.uploadedFiles[i], this.uploadedFiles[i].name);
  }
  this.http.post('/api/upload', formData)
    .subscribe((response) => {
    console.log('response received is ', response);
  })
}
Disturbed Dunlin

upload de arquivo no angular 10

onFileChange(event) {
    const reader = new FileReader();

    if (event.target.files && event.target.files.length) {
      const [file] = event.target.files;
      reader.readAsDataURL(file);
      reader.onload = () => {
        this.data.parentForm.patchValue({
          tso: reader.result
        });

        // need to run CD since file load runs outside of zone
        this.cd.markForCheck();
      };
    }
  }
Zany Zebra

Respostas semelhantes a “upload de arquivo no angular 10”

Perguntas semelhantes a “upload de arquivo no angular 10”

Procure respostas de código populares por idioma

Procurar outros idiomas de código