How to delete file from folder using javascript?

前端 未结 6 1022
故里飘歌
故里飘歌 2020-12-16 00:51

Is there any way to delete files from folder using javascript..? Here is my function

function deleteImage(file_name)
    {
        var r = confirm(\"Are you          


        
6条回答
  •  难免孤独
    2020-12-16 01:08

    You cannot delete anything without any server-side script..

    You can actually use ajax and call a server-side file to do that for e.g.

    Make a file delete.php

    
    

    and in the javascript

    function deleteImage(file_name)
    {
        var r = confirm("Are you sure you want to delete this Image?")
        if(r == true)
        {
            $.ajax({
              url: 'delete.php',
              data: {'file' : "" + file_name },
              success: function (response) {
                 // do something
              },
              error: function () {
                 // do something
              }
            });
        }
    }
    

提交回复
热议问题