Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] Arrrg! Permissions driving me nuts in PHP



TLUG,

In a PHP script I have, I use mkdir() to create a directory and put some
files in it.

It's just a temporary directory to organize some files that I bundle
into a tar.gz file and store away.

After I've got the tar file made, I want to delete the temp directory. I
use the code included at the bottom (which I took from the PHP manual
site) to recursively delete the directory and its subdirectories and files.

However, when I run the code, I get permission errors:
Warning: unlink(/home/site/public_html/+backup/someFileOrOther)
[function.unlink]: Permission denied in
/home/site/public_html/backup.php on line 115

How can a directory I just made a few lines earlier in a PHP script have
permissions that don't permit the very same script that created it to
delete it a few lines later?

More importantly, how do I remove the $%&#ing thing?

Thanks for any advice. The aforementioned delete function is included
below for reference:

function rrmdir($dir)
    {
        if (is_dir($dir))
        {
            $objects = scandir($dir);
            foreach ($objects as $object)
            {
                if ($object != "." && $object != "..")
                {
                    if (filetype($dir . "/" . $object) == "dir")
                        rrmdir($dir . "/" . $object); else
                        unlink($dir . "/" . $object);
                }
            }
            reset($objects);
            rmdir($dir);
        }
    }

-- 
Dave M G


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links