Search This Blog

delete a file in php

<?php

if(isset($_POST['fname']))
{
  if(!empty($_POST['fname']))
  {
       $name=$_POST['fname'].'.txt';
  if(@!unlink($name))
  {
      echo 'there is no file to delete';
  }
  else
      echo 'file successfully deleted';
     }
}
?>

<form action="file-delete.php" method="POST">
file name : <input type="text" name="fname">
.txt
<input type="submit" value="submit">
</form>

output :
 note :
1) enter the file name  for delete that text file

Share Links

Related Posts Plugin for WordPress, Blogger...