This section contains the detail about deleting file in PHP.
In PHP, file can be delete using unlink() function. The unlink() function need only the file name to be delete.
But you must ensure that it is not open in your program. You can use fclose() to close the open file.
Given below example code delete the file "NewtestFile.txt" as follows :
<?php $myFileName = 'C:\NewtestFile.txt'; unlink($myFileName); echo "File deleted successfully"; ?>
File deleted successfully