What are the potential reasons for not being able to delete directories even after setting permissions to 777?
Even after setting permissions to 777, you may not be able to delete directories due to the presence of immutable flags, extended attributes, or SELinux restrictions. To solve this issue, you can use the `chattr` command to remove any immutable flags or extended attributes on the directory.
exec("chattr -i -a /path/to/directory");
exec("rm -rf /path/to/directory");