How to delete a file with javascript?

前端 未结 7 1153
栀梦
栀梦 2020-12-18 06:54

Did not have luck with these examples:
Javascript File remove
Javascript FSO DeleteFile Method
Deleting a File

There are no special permissions on the fi

7条回答
  •  旧巷少年郎
    2020-12-18 07:37

    You can't delete files with JavaScript as it is run locally. So, it doesn't even touch external files.

    You need to use a server side language that has access to editing the files such as PHP, RoR, or ASP.

    You can however use jQuery to call the server side code via AJAX such as $.get or $.post and then the server side code deletes it and it would seem as though JS is deleting the files.

提交回复
热议问题