You cannot closedir()
on a directory that has not previously been opened (and stored in a filehandle) with the opendir()
PHP function. If you want to closedir()
you will need to get a filehandle to this directory first using opendir()
. This is per the PHP manual: http://php.net/manual/en/function.closedir.php
Additionally, if you want to rmdir()
a directory, it needs to be completely empty and you need the appropriate permissions. Otherwise, you will get errors. This is also per the PHP manual: http://php.net/manual/en/function.rmdir.php