function deletefiles($directory)
{
$folder = glob($directory); // <--error on this line.
foreach($folder as $file)
{
if(is_dir($file))
{
deletefiles($directory);
}
else
{
unlink($file);
}
}
if(is_dir($directory))
{
rmdir($directory);
}
}
That’s the code causing the error. The function is supposed to delete all files and subdirectories of a specified folder. Each folder only contains maybe 5 maximum subfolders.
This function worked when there was only files in the folder. Any insight would be greatly appreciated.
There are 2 places needed to fix.