Creating a Folder

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
User avatar
iknownothing
Forum Contributor
Posts: 337
Joined: Sun Dec 17, 2006 11:53 pm
Location: Sunshine Coast, Australia

Creating a Folder

Post by iknownothing »

Hey Guys,

I have the following code:

Code: Select all

$checkfile = "../" . $catName . "/" . $sectName;
if (!file_exists($checkfile)) {
	mkdir($checkfile, 0777);
}
What I need to happen is, if it doesn't find the $sectName folder within the $catName folder, it should then create the $sectName folder.

All well in theory, but I get the feeling that the mkdir and file_exists functions, do not use "../" to access one level up. I keep getting "No Such file or directory" errors when using this code.

Also, the $catName folder will always exist, if that matters.


Is there anything I can do to fix the problem?

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you sure you are referencing $catName correctly? You can check with getcwd().
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

You're not making a $sectName folder, you're making a $checkfile directory.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply