I want to make directories for users that are located outside the root of the site. These folders will contain files they end up uploading. But I'm realizing right now as I am trying to do it, that I don't know how to do it.
The only way I know how to make directories is within the site itself.
PHP Code:
mkdir("new_folder", 0775);
Can someone tell me how to make a directory above the root?
Use an absolute path or a relative path and move up above the public_html. If this file is currently located directly under public_html, you can get above there using ../.
Privilege wise you may need to manually create a directory that's sibling to the public_html and assign the additional privileges. If you cannot create in the ~/ directory (assuming public_html is directly below ~), then I wouldn't suggest opening it up. I would suggest creating the adjacent one and adding the necessary permissions to it.
Initially I couldn't even make a directory within the root but then I went into the server and changed the permissions for the folder the site exists in, and now I can at least do that. But even with the file permissions set wide open on /httpdocs/ and httpdocs/users/ it still won't make a directory.
Last edited by cgdtalent; 01-09-2013 at 02:21 AM..
I got it to finally work. I had to set the open_basedir to allow or include the directory I was creating the folder within. I'm not sure if this is a good thing to do but it worked. But here is the setting before on open_basedir:
Is the httpdocs the parent of public_html, or is it the directory in use for serving the http docs out of?
The use should be fine. The purpose of this directive is to force PHP to only open files in specific locations in the filesystem tree. This appears to be tight enough IMO (although I don't know what the {DOCROOT} is); the ones to really watch for are / and . since both of these can be heavily exploited (baring permissions of course).
Another problem I often see with this is the umask as well. Seems to me that you're okay on yours though.
Is the httpdocs the parent of public_html, or is it the directory in use for serving the http docs out of?
The use should be fine. The purpose of this directive is to force PHP to only open files in specific locations in the filesystem tree. This appears to be tight enough IMO (although I don't know what the {DOCROOT} is); the ones to really watch for are / and . since both of these can be heavily exploited (baring permissions of course).
Another problem I often see with this is the umask as well. Seems to me that you're okay on yours though.
the directory httpdocs is above the root of the site and is outside of it. Here would be a view of the server at its highest level:
- httpdocs
- site ------> html files in this directory
- private
- cgi-bin
So maybe the site should have been put in the httpdocs folder, but it wasn't. It was placed outside of it. I don't know enough about servers to know if this is ok, but I'm hoping it is.