note 22879 modified in function.mkdir by vincent
| From: | vincent@php.net | Date: | Sat, 16 Aug 2003 14:45:49 +0000 |
| Subject: | note 22879 modified in function.mkdir by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54372@lists.php.net to get a copy of this message | ||
I am not sure if this is only a Win/Win2k problem.
However when using mkdir on this system to create a folder you can ONLY create a folder under an
existing folder
that is if you have c:\tmp
which is an empty folder
mkdir("c:\tmp\new",0777); WILL WORK
however
mkdir("c:\tmp\new\new2\new3",0777) WILL NOT WORK as the subdirectories new and new2 do not
exist and windows does not make them for you.
use the following in such cases
$the_path="c:\tmp\new\new2\new3";
if(!file_exists($the_path)) {
$a="";
foreach(explode("/",$the_path) AS $k) {
$a.=$k."/";
if(!file_exists($a)) mkdir($a, 0777);
}
}
--was--
I am not sure if this is only a Win/Win2k problem.
However when using mkdir on this system to create a folder you can ONLY create a folder under an
existing folder
that is if you have c:\tmp
which is an empty folder
mkdir("c:\tmp\new",0777); WILL WORK
however
mkdir("c:\tmp\new\new2\new3",0777) WILL NOT WORK as the subdirectories new and new2 do not
exist and windows does not make them for you.
use the following in such cases
$the_path=""c:\tmp\new\new2\new3";
if(!file_exists($the_path)) {
$a="";
foreach(explode("/",$the_path) AS $k) {
$a.=$k."/";
if(!file_exists($a)) mkdir($a, 0777);
}
}
http://www.php.net/manual/en/function.mkdir.php