
Imagine a remote control to delete all files in server from a particular folder as soon you type that url and hit enter.
Here is the code:
<?php
// PHP program to delete all files
// from a folder
// Folder path to be flushed
$folder_path = 'getcwd();';
// Assigning files inside the directory
$dir = new DirectoryIterator(dirname($folder_path));
// Deleting all the files in the list
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot()) {
// Delete the given file
unlink($fileinfo->getPathname());
}
}
?>
Where to put this code?
Make a PHP file like example.php and put this file inside the folder with all the files you want to delete.
For example you want to delete all files under folder “website_staging” and url of the the folder is “example2.com/wp-content/website_staging” , put that file example.php inside “website_staging”
How to run the code?
Type in URL “example2.com/wp-content/website_staging /example.php” and hit enter, you will see all files under folder “website_staging” is gone.
Share this article if it helps.










