RE: [PHP] mkdir() only makes one folder level deep.

From: Date: Thu, 22 Aug 2002 19:53:53 +0000
Subject: RE: [PHP] mkdir() only makes one folder level deep.
Groups: php.general 
Request: Send a blank email to php-general+get-113671@lists.php.net to get a copy of this message
Hello Shane, Here is some sample code that I've used on Unix, you may have to adapt it, etc. I verified this works on my Unix machine but the code as-is. Jason <?php function mkdir_parents($dir) { //seperate directory at /, this would have to be changed for windows $directories = explode("/", $dir); foreach ($directories as $directory) { $dirstring .= $directory . '/'; if (!is_dir($dirstring)) { mkdir($dirstring); } } if (is_dir($dir)) { return 1; } else { return 0; } } /* dir is the directory that will be created */ $dir="/home/jsheets/www/testdir/subdir1/subdir2"; /* call mkdir_parents with the path that needs to be created */ if (mkdir_parents($dir)) { print 'directory created!'; } else { print 'directory not created :('; } ?> -----Original Message----- From: Shane [mailto:shane@delaplaine.com] Sent: Thursday, August 22, 2002 12:58 PM To: php-general@lists.php.net Subject: [PHP] mkdir() only makes one folder level deep. I have read that mkdir() (ON WINDOWS) will only make ONE file directory level deep at a time. So if you need two directories, one inside another, you can NOT specify this in one line like... mkdir(/top/middle/bottom,0700); Is this true? If so, what is the work around??? Thanks gang! -NorthBayShane -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#113671) next »