Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

172
Vistas
Not able to reset input type file value on delete button click using Angular

I am trying to reset the input type file value after user click on delete button using Angular so that user can upload same file again after deletion but as per my code its not working. I am explaining my code below.

<label [for]="'file' + i" style="width: 100%;cursor: pointer;text-align: center;">
                  <div id="drop_zone" (drop)="dropPayLoad($event, i, fileType.CONFIG_FILE)" (dragover)="allowPayloadDrop($event, i, fileType.CONFIG_FILE)">
                    <span class="pat-span">{{fileLableArr[i]['config_name']}}</span>
                    <input type="file" hidden [id]="'file' + i"
                      (change)="handleUploads($event.target.files, fileType.CONFIG_FILE, i)">
                    <span *ngIf="fileLableArr[i]['isConfig']" style="position: relative;top: 6px;left: 5px;font-size: 31px;"
                        (click)="$event.preventDefault();deleteUploadedFile($event, fileType.CONFIG_FILE, i)">&times;</span>
                  </div>
                </label>

Here I have file inputs inside one table and after uploading file user can delete that file. Here my issue after deletion of that file if user need to upload same file again then it is not happening. So in this case file input need to be clear. By google search added code like (click)="this.value = null" but it did not work. Here at the time of deletion the file input should be reset so that user will able to upload same file again. please try to help me resolve this issue.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Clear he value in the handleUploads method itself.

Modify you handleUploads like this, pass other params as per your code:

handleUploads(event) {
  // Get your files
  const files: FileList = event.target.files;

  // do whatever you want with the files

  // At the end clear the input
  event.target.value = null;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda