Re: Chmod a Directory

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

 



On 10/9/07, Stut <stuttle@xxxxxxxxx> wrote:
> abderrazzak nejeoui wrote:
> > Please how can i chmod a directory to 0777
> > i tried chmod ($myDirectory, 0777); but nothing happens
>
> Check the return value. If it's false then it's failing for some
> reason., most likely because the user it's running as doesn't have
> permission to extend the permissions on that directory that far.
>
> Also make sure you read the notes here: http://php.net/chmod
>
> -Stut
>
> --
> http://stut.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

    Once again, Stut is most likely correct.  Chances are the
directory was created by someone other than as whom the script is
being run.  If you're server isn't configured to use phpSuExec, sticky
bits, or a similar setup, then chances are that you created the
directory as your user account (via FTP, SSH, a file manager, etc.),
and are attempting to chmod() the directory as Apache's user (nobody,
httpd, daemon, apache, etc.).

    If that's the case, your best bet is to remove the directory using
the same medium with which you created it (if you can), and add the
following above your chmod() line:

<?
$directory = "myDirName";
if(!is_dir($directory)) mkdir($directory);
chmod($directory,0777);
?>

    However, another point to keep in mind is that, if you do things
correctly, you should never need a directory to be 0777 (everyone can
read, write, and execute), as that's a serious potential security
risk.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Give a man a fish, he'll eat for a day.  Then you'll find out he was
allergic and is hospitalized.  See?  No good deed goes unpunished....

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux