I'm having difficulties having my script automatically create new directories upon account registration.
$bloguser=$_POST['bloguser'];
$root = "/accounts/";
if(!is_dir($root.$bloguser, 0777))
mkdir($root.$bloguser, 0777);
if(!is_dir($root.$bloguser."/images", 0777))
mkdir($root.$bloguser."/images", 0777);
if(!is_dir($root.$bloguser."/images/avatar", 0777))
mkdir($root.$bloguser."/images/avatar", 0777);
The account registers just fine. However, the is_dir and mkdir are giving me errors:
Warning: Wrong parameter count for is_dir() in...
Warning: mkdir() [function.mkdir]: Unable to access /accounts/TestAccount in...
Warning: Wrong parameter count for is_dir() in...
Warning: mkdir() [function.mkdir]: Unable to access /accounts/TestAccount/images in...
Well, you get the idea.
accounts
folder in the root those 0777 writing rights, just to make sure the writing rights aren't the problem;Thanks in advance for your help. :)
There is a much simpler way. mkdir
has recursive
option:
mkdir($root.$bloguser."/images/avatar", 0777, true);
The first thing always to do when programming PHP, is reading the documentation. There is a lot in there and the community comments often address common problems.