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

417
Vistas
Can a local file be deleted by a html button( integrating html button with javascript, jquery or anything else)?

I have a html table which shows all the files present in a local directory.

enter image description here

There is a remove button which deletes corresponding row of the table. Below is the code for that:

    $(document).ready(function(){
     $("#myTable").on('click','.btnDelete',function(){
         $(this).closest('tr').remove();
      });
  });
<td><button type='button' class='btnDelete'>x</button></td>

But this button only removes the row from the table and as I refresh my page, it again shows that file because its still there in the working directory.

What I want is to delete file from directory itself. So that next time when I refresh my webpage, it will not show that file again.

Is this possible to achieve this? Can I delete a file from my local directory using html button? If yes, please suggest how.

P.S. Below is the code which I used to create the table:

<table id="myTable" style="width:100%">
  <tr>
    <th>Select One</th>
    <th>File Name</th>
    <th>File Size</th>
    <th>File Type</th>
    <th>Remove</th>
    
  </tr>
  {% for file in files %}
    <tr>
    <td><input type="radio" name="myRadio" id="data"></td>
      <td>
      <a href="{{ (request.path + '/' if request.path != '/' else '') + file }}" id="data">
          {{ file }}
      </a>
    </td>
    <td>
          fileSize
    </td>
    <td>
      <p>pdf</p>
    </td>
    <td><button type='button' class='btnDelete'>x</button></td>
    </tr>

  {% endfor %}
</ul>
</table>

Edit 2: This is my working directory setup:

enter image description here

Files which I am showing in html table are under /uploads.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Simple HTML/Javascript webpage page cannot delete files from the computer. Just imagine the havoc it could create if you'd visit a webpage and it deleted files from your computer... However if you run a webserver with phpor nodejs on the same machine, than it can be done.

If your objective simply hide file from the table, you could store the list of "deleted" files in localstorage and in the code that generates the table check each file against localstorage database. I'm not familiar with the type of template you are using, so can't really show you an example

over 4 years ago · Santiago Trujillo 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