This project is a simple yet powerful PHP utility created by Ashikur Rahman Provat. It is designed to safely and recursively delete a folder along with all its files and sub-folders.
The PHP Recursive Directory Deleter handles nested structures and automatically manages file permissions (chmod) to ensure smooth deletion.
For more tools and web development services, visit arprovat.com.
- Recursive Deletion: Deletes everything inside a directory, including nested sub-folders.
- Auto Permission: Automatically sets
chmod 0777to files and folders before deletion. - Safe Handling: Checks if the path is a valid directory before proceeding.
- Lightweight: Pure PHP logic without any external dependencies.
Server: PHP (opendir, readdir, unlink, rmdir)
- You must have a PHP-supported server (e.g., Laragon, XAMPP, or Linux Server).
- Create a
force-delete.phpfile and paste the script. - Set your target folder name at the top of the script:
$target_dir = 'your_folder_name_here';- Run the script via browser or terminal:
php force-delete.php
This tool is permanent and cannot be undone. Once a directory is deleted, the data is gone forever. Please double-check the $target_dir path before running the script.
Contributions are welcome! If you'd like to add a GUI or extra safety features, feel free to fork the repository and submit a pull request.
If you encounter any issues or have suggestions for improvement, please open an issue on GitHub.