Creating directory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Yourchild
Forum Newbie
Posts: 16
Joined: Mon Jul 30, 2007 3:04 pm

Creating directory

Post by Yourchild »

I have a piece of code that looks like this:


if($makeDir) {
mkdir($pathToRoot.$uploadDir);
}


I am receiving a warning "Permission Denied". How do I obtain permission for creating this directory?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

If you're running PHP in safe_mode then mkdir() will be unavailable. There's no way around it.

If you're not, then check that the directory you're trying to make the new directory in is writeable.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If the directory is outside your web-root, you'll typically need to talk to the host, or do it manually within your control panel. If the directory is inside your web-root, when disallowed, your host has likely chosen to not give php that permission due to security concerns.

Are you sure the directory is correctly located and set?
User avatar
nathanr
Forum Contributor
Posts: 200
Joined: Wed Jun 07, 2006 5:46 pm

Post by nathanr »

it also depends where the link is relative to.. I've noticed on a few of boxes that apache is only allowing mkdir to run when specifying the directory by relative link, rather than absolute path.. (also check you don't have a slash missing..

try just mkdir('testdir') and see where it ends up, then write a rel path to where you want :)
Post Reply