Jump to content

[SOLVED] Trying to create subdirectories?


BigDC

Recommended Posts

Hello,

I am on a hosting account that has PHP Version 5.2.9.

 

I am trying to create sub directories within a directory. The script I use is in a sub directory named members inside my home directory, my home directory is /home/playerz, and my public html html directory path is /home/playerz/public_html. I get info from a form using $_POST['memberType'] and $_POST['userName'], and and then I am trying to create sub directories inside of the members sub directory

 

So the sub directories with the structures I want to create are:

/members/$memberType/$userName

/members/$memberType/$userName/mp3

/members/$memberType/$userName/images

/members/$memberType/$userName/include

 

Here is my code so far:

$memberType = $_POST['memberType'];
$userName = $_POST['userName'];

$thisdir = dirname("/members/{$memberType}/{$userName}");
mkdir($thisdir, 0777);

$thisdir = dirname("/members/{$memberType}/{$userName}/mp3");
mkdir($thisdir, 0777);

$thisdir = dirname("/members/{$memberType}/{$userName}/images");
mkdir($thisdir, 0777);

$thisdir = dirname("/members/{$memberType}/{$userName}/include");
mkdir($thisdir, 0777);

 

When I use this code, I get the following errors:

Warning: mkdir() [function.mkdir]: No such file or directory in /home/playerz/public_html/accountcreated.php on line 47

 

Warning: mkdir() [function.mkdir]: No such file or directory in /home/playerz/public_html/accountcreated.php on line 49

 

Warning: mkdir() [function.mkdir]: No such file or directory in /home/playerz/public_html/accountcreated.php on line 51

 

Warning: mkdir() [function.mkdir]: No such file or directory in /home/playerz/public_html/accountcreated.php on line 53

 

I have checked to make sure that $memberType and $userName are getting the variables posted to them, and they are.

 

Please help?

Link to comment
https://forums.phpfreaks.com/topic/176924-solved-trying-to-create-subdirectories/
Share on other sites

does /members/{$memberType} exist ?

also dirname should be used with FILE paths

 

try

mkdir("/members/{$memberType}", 0777);
mkdir("/members/{$memberType}/{$userName}",0777);
mkdir("/members/{$memberType}/{$userName}/mp3",0777);
mkdir("/members/{$memberType}/{$userName}/images",0777);
mkdir("/members/{$memberType}/{$userName}/include",0777);

you're trying to create the directories in the root of the drive... you should include your home directory before '/members/....'

 

$thisdir = dirname("/home/playerz/members/{$memberType}/{$userName}");

 

or really just...

 

$thisdir = "/home/playerz/members/$memberType/$userName";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.