Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

415
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda