I've researched however i can't appear to obtain my script to operate.

this really is my code

if (is_dir("tmp")) {
    if (substr(sprintf("%o", fileperms("tmp")), -4) == "0777") {
        echo "good";
    } else {
        echo "going to chmod the tmp folder to 777";
        if (!chmod("tmp", octdec(0777))) { // tried chmod("tmp, 0777) too
                echo "Oops, I couldn't chmod the /setup/tmp directory, please do this manually";
} else {
    echo "we'll make the folder";

I can not appear to obtain the chmod to operate, i just read somewhere when register globals was off than the wouldn't work(i've that setting set to off).

I adopted the PHP.internet manual and a few of the good examples they provided there within the user comments, in addition to some stack-overflow posts which i found relevant. but possibly i have to tweak some php configurations to get this work?

It is possible to method of getting the chmod function to operate without requiring to alter the PHP.ini?

Represent such as this:-

chmod("tmp", 0777);

You have not provided us with enough information to find out why [cde] is failing. Maybe the net-server does not plenty of rights to change directory permissions.

Who owns the net-server process should own your directory or perhaps be part of the possessing group. For instance, if root is the owner of tmp, as well as your web-server is running because the user 'apache', it won't be easy to customize the directory's permissions from PHP.

In my opinion the configurations you mention in php.ini are for debugging, not like magic 'fixing' chmod(). Try prepending the next lines of code for your PHP script and you ought to have more helpful debug output:


The consumer that's running the php daemon or web server daemon should have write accessibility directory you are attempting to chmod. During my situation, www-information is the consumer that's running php and then any instructions that php is attempting to operate, it will likely be run because the www-data user.

Should you produce a directory while using php mkdir function, you will see that who owns your directory is whatever person is running the php or webserver daemon. And then any directory which was produced by php, php will have the ability to chmod, chown, do anything whatsoever into it since it is the dog owner.

You may either

  1. chown your directory to ensure that the dog owner may be the php user
  2. set writing rights for that group and hang the audience towards the same group because the php user
  3. make a move like giving sudo rights towards the php user which isn't suggested btw.