How to use PHP & Unlink() Delete File Learn how to use the PHP to Delete File on web server and using function Unlink ()
ShotDev Focus:
- PHP & Delete File (Unlink())
Example
php_delete_file.php
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- <?
- $flgDel = unlink("shotdev/my.txt");
- if($flgDel)
- {
- echo "File deleted.";
- }
- else
- {
- echo "Cannot delete file.";
- }
- ?>
- </body>
- </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_delete_file.php
Screenshot