Delete a file in PHP

Description

The following code shows how to delete a file.

Example


 //w ww.j  ava 2  s .c  o  m
  
<?php
     $file = "test.txt";
     if (!unlink($file)){
         echo ("Error deleting $file");
     }else{
         echo ("Deleted $file");
     }
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip