note 96188 added to function.mkdir
| From: | support at addcomment dot ru | Date: | Fri, 12 Feb 2010 23:13:06 +0000 |
| Subject: | note 96188 added to function.mkdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165926@lists.php.net to get a copy of this message | ||
how to create 'dir1/dir2/dir3/...' folders, with full error support:
<?
#recursive dir creating
function mkdirr($p,$m) {
$e="mkdir: unable";
foreach(explode('/',trim($p,'/')) as $d) {
if(empty($d)||$d=='/') break;
if(!@is_dir($d)) {
if(file_exists($d)) die("{$e} to create folders: '{$p}' -- '{$d}'
EXISTS AS FILE!");
if(!@mkdir($d,$m)) die("{$e} to create folder: '{$d}' in path:
'{$p}' .. permissions?");
}
if(!@chdir($d)) die("{$e} chdir({$d}) , path: '{$p}' .. huh?");
}
}
?>
mkdir('/upload/files/21-02/',077)
has been created/checked dirs with permissions 0777 (rxwrxwrxw)
----
Server IP: 78.41.104.8
Probable Submitter: 124.157.170.222
----
Manual Page -- http://www.php.net/manual/en/function.mkdir.php
Edit -- https://master.php.net/note/edit/96188
Del: integrated -- https://master.php.net/note/delete/96188/integrated
Del: useless -- https://master.php.net/note/delete/96188/useless
Del: bad code -- https://master.php.net/note/delete/96188/bad+code
Del: spam -- https://master.php.net/note/delete/96188/spam
Del: non-english -- https://master.php.net/note/delete/96188/non-english
Del: in docs -- https://master.php.net/note/delete/96188/in+docs
Del: other reasons-- https://master.php.net/note/delete/96188
Reject -- https://master.php.net/note/reject/96188
Search -- https://master.php.net/manage/user-notes.php