Re: Can't Make Directories Now

From: Date: Mon, 01 Sep 2003 22:41:00 +0000
Subject: Re: Can't Make Directories Now
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-161393@lists.php.net to get a copy of this message
* Thus wrote Seth Willits (seth@freaksw.com): > <?php > $path = "path/path2/path3/path4/path5"; > $buildingPath = "existingFolder"; > $pathComponents = split("/", $path); > > > foreach ($pathComponents as $value) { > $buildingPath = $buildingPath . "/" . $value; > print $buildingPath . '<br>'; > > if (opendir($buildingPath) == false) There is a lot of overhead with using opendir just to see if the directoy exists other alternatives you might want to use is: php.net/stat php.net/is_dir Or you can use the system's mkdir command wich usually has a paramater to make all directories if they don't exist: mkdir -p path/to/new/dir/ > if (!mkdir($buildingPath)) > print 'false <br>'; A print("false $buildingPath<br>") might yield as to why it isn't creating it. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#161393) next »