Jump to content

MKDir Upon New Registration


hobbiton73

Recommended Posts

Hi, I wonder whether someone may be able to help me please.

 

I'm fairly new to PHP so please bear with me.

 

I'm trying to put together a script which bascially creates a hierarchical tree of folders upon a new account being created by a user.

 

I would like to take the 'username' that the user registers with to use as the name for the first folder, then, create a folder at the second level called 'images' and then finally, a folder within that called 'thumbs'.

 

From the research that I've done, I believe that I need to use the 'mkdir' command, but I can't find a very straight forward tutorial.

 

I just wondered whether someone could perhaps please help me out with this, so that I at least have a good solid starting point.

Link to comment
https://forums.phpfreaks.com/topic/253957-mkdir-upon-new-registration/
Share on other sites

Something like this:

 

$root = "/path/to/users/";
$username = $_POST["username"]; // A pre-validated username
if(!is_dir($root.$username))
mkdir($root.$username);
if(!is_dir($root.$username."/images"))
mkdir($root.$username."/images");
if(!is_dir($root.$username."/images/thumbs"))
mkdir($root.$username."/images/thumbs");

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.