Hey guys. I am trying to automaticaly create directories from a webpage on my server and set the permissions.

I have tried the obvious mkdir($path) and I have tried the not so obvious exec("mkdir -m 0777 $path").

The latter used to work on another server, but no longer does now. The former creates the directory but it is owned by Apache and the permissions are set to 0 so i cannot even open thru my ftp program or add files to it.

In the php.ini I have

safe_mode=off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
;open_basedir =

the open base dir is commented out as you can see and include and exec have no values, as you can see.

So is there something I need to change in the ini file?

Thanks.

BTW, the PHP version is 5+

    According to the manual, the default permission for [man]mkdir/man is 0777, though you can set it explicitly via the optional second parameter (although it's ignored if on a Windows system).

      Yah it is supposed to be 0777 by defualt, but I also put in the 0777 and it still isn't right.

      mkdir($path,0777) still says the owner is Apache and permissions are "rwx --- ---".

      I can't add anything into the folders via PHP or manualy and I can't even change the permissions manualy. In fact, if I try to open the folder Via Dreamweaver it is the folder doesn't even exist....

      Anyone have a clue what the issue could be?

      Thanks.

      This is a lynux system btw.

        Does the PHP [man]chmod/man function do anything?

          Thanks for the response.

          I tried using chmod after the mkdir and the folder is now saying the permissions are "rwx rwx rwx" which means it has full access. However, when I try to upload a file to it thru PHP it won't upload, says I don't have permission.

          I am pretty confused now..../heavy sigh.

          I am sure it has to do with the user and group being Apache, whereas if I make the folders manualy the user and group are different.

          Apparently PHP is not allowed to upload files to folders owned by Apache?

          How do I change this?

          Thanks.

            Write a Reply...