How to delete file from folder using javascript?

前端 未结 6 1015
故里飘歌
故里飘歌 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:10

    You can not delete files with javascript for security reasons.However, you can do so with the combination of server-side language such as PHP, ASP.NET, etc using Ajax. Below is sample ajax call that you can add in your code.

    $(function(){
    $('a.delete').click(function(){
      $.ajax({
       url:'delete.php',
       data:'id/name here',
       method:'GET',
       success:function(response){
        if (response === 'deleted')
        {
           alert('Deleted !!');
        }
       }
      });
    });
    });
    

提交回复
热议问题