Delete All Files In a Directory In a Loop using php
Delete All Files In a Directory In a Loop using php,
In order to use the PHP rmdir() function which removes a directory folder, that target folder must be empty in order for the folder to be deleted. So first we have to delete all files that are inside of it. Or you might just require a script that will empty a folder of its files on occasion.
$dir = "myFolder/";
$files = opendir($dir);
while ($file = readdir($files))