How can I delete an excel file form server with Javascript Apache I try this code but no works.
var r = confirm("Are you sure you want to delete this File?")
if(r == true)
{
$.ajax({
url:'delete.php',
data:'https://example/server/index.xlsx',
method:'GET',
success:function(response){
if (response === 'deleted')
{
alert('Deleted !!');
}
}
});
}
delete.php
<?php
unlink($_GET['file']);
?>
2
Answers
Next time you should include the error message(s) you get so its easier for whoever is helping to understand your problem.
Try this
This is your PHP delete.php file content
First of all, you can’t delete files with JS as it is run locally. You need to use server-side file to do that.
delete.php
// Ajax file