You cannot delete files via HTTP (well, theoretically you can, but this is not implemented.)
The easiest way is to configure the tiny server side of the script (e.g. in ASP or PHP) and call it from JavaScript. The server side of the script needs proper permissions to delete, but otherwise there is no problem.
In PHP, the beginning will look like this: (Without extending the solution to be completely secure, because you are not saying what platform you are on)
<? // STILL INSECURE!!!! // Do not use in any public place without authentication. // Allows deletion of any file within /my/files // Usage: filename.php?file=filename $basedir = "/my/files"; $file_to_delete = $_REQUEST["file"]; $path = realpath($basedir."/".$file_to_delete); if (substr($path, 0, strlen($basedir)) != $basedir) die ("Access denied"); unlink($path); ?>
you call the script like this:
http://yourserver/directory/delete_file.php?file=directory/filename
source share