Home / PHP Tips Generated By ChatGPT / Deleting a File in PHP Use unlink() to delete a file. Source Code $filename = "delete_me.txt"; if (unlink($filename)) { echo "File deleted successfully."; } else { echo "Could not delete the file."; }