is it possible to delete a file(s) inside the directory by just using javascript ?. what I currently have is, an index.php which displays the name of the files in the same directory and and a checkbox to each file name and at the bottom is a delete button. what I want to happen is, delete all the selected checkboxes once the delete button is clicked. I am not using mysql here, just a plain php file that displays the names. can someone show me how to delete the selected files using javascript ?
Share
You can not delete files with javascript for security reasons. Bad guys can delete files of your stytem 🙁 However, you can do so with the combination of server-side language such as PHP, ASP.NET, etc using what is know as Ajax.
Note: Javascript is moving to adding/becoming the server-side language options. Node JS is an example of that.
Update Based On Comment:
You can delete files something like this:
JQuery:
PHP: