Jump to content

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";

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.