[PHP] Can't Make Directories Now
I figured out the permissions issue to allow gd to create image files, but I also need to create folders for those images. I've come up with a routine (below) but it fails to create the directories. I've made sure that the directory that the first directory is created in has the appropriate permissions, but it doesn't work. foreach ($pathComponents as $value) { $buildingPath = $buildingPath . "/" . $value; print $buildingPath . ''; if (opendir($buildingPath) == false) if (!mkdir($buildingPath)) print 'false '; else closedir($buildingPath); } ?> The paths to the folders its supposed to create are correct ($buildingPath), but it always prints false signaling that mkdir has failed. This is the last remaining issue on getting my site finished. Well except for uploading, but I don't need that just yet. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "It's all about the belly fire." -- David Sepe --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't Make Directories Now
* Thus wrote Seth Willits ([EMAIL PROTECTED]): >$path = "path/path2/path3/path4/path5"; > $buildingPath = "existingFolder"; > $pathComponents = split("/", $path); > > > foreach ($pathComponents as $value) { > $buildingPath = $buildingPath . "/" . $value; > print $buildingPath . ''; > > 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 '; A print("false $buildingPath") 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." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't Make Directories Now
On Monday, September 1, 2003, at 03:41 PM, Curt Zirzow wrote: print $buildingPath . ''; if (opendir($buildingPath) == false) if (!mkdir($buildingPath)) print 'false '; A print("false $buildingPath") might yield as to why it isn't creating it. I already did that and like I said, it's always the correct path. Look at the very first line of the code above which was in the original path. Thanks for the tip on is_dir. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Rather fail with honor than succeed by fraud." -- Sophocles --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't Make Directories Now
print $buildingPath . ''; if (opendir($buildingPath) == false) if (!mkdir($buildingPath)) print 'false '; A print("false $buildingPath") might yield as to why it isn't creating it. I already did that and like I said, it's always the correct path. Look at the very first line of the code above which was in the original path. Thanks for the tip on is_dir. Actually -- using is_dir made it work. I wonder why Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Read the book! Be patient! All success comes from acquiring knowledge and experience." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php