Thanks glence for your reply since it helped me to get the mkdir working on my PC (WIN2000) with your example mkdir("c:/windows/ss/",0700).

Now I am trying to get this to work on my site which is hosted on a unix system. I've also been able to successfully execute mkdir there but I had to change the permissions of the directory to 777 before I could make it work.

My problem is this:

I need to open new directories in my root directory which now is configured with unix permissions 755. In order to use mkdir and open new directories there (the root dir) by changing the root directory permissions to 777 is surely the wrong solution (the idea scares me).

QUESTION:
Is there any way I can use mkdir to create a new directory on a folder with permission of 755 ?? These things are pretty confusing for me.

If anyone can give me a pointer or two on my question Iit would be much appreciated.

Thanks to everyone.

George

    Hello!

    You probably need to change the ownership of the directory.

    Your webserver is running as a certain user (ie. apache or www-data).

    If that user does not have access to write to
    that directory then your mkdir will fail.

    So if you want to create a folder in say
    /tmp/mystuff/

    called
    data/ (/tmp/mystuff/data)
    then you should change the ownership of "mystuff".

    Do this by saying:
    chown apache /tmp/mystuff

    You can also at the same time change the group by saying:
    chown apache.apache /tmp/mystuff

    (assuming your webserver runs as user "apache")

    I see the php function is:
    chown("/tmp/mystuff", "apache");
    but I'm not sure that it will work since
    you already dont have permission to
    change things.

    Log in as root.

    hope that helps!

    bye!

      Write a Reply...