View Full Version : Giving users own directory

08-01-2012, 09:41 AM
Im not sure if this is done with PHP, but im guessing it could be.
Basically what I want is users to rather have or make it appear as they have their own directory.
Basically instead of heaving a URL as:

I want it to be:

How do I do this?
Would I have to make some code which creates a new folder for each new user that registers with a file within that.
Or is there a way around it in the code without having to create 1000s of new folders for the 1000s of users signing up.


08-01-2012, 11:39 AM
mkdir("/path/to/my/dir", 0700);

08-01-2012, 01:31 PM
Or you could use a .htaccess file and have a rule that rewites the url so it appears as if they have their own directory, but instead it is returning ?user=username.

08-01-2012, 04:03 PM
Make a 'big' directory, separate from all the other directories and files, to keep the user directories in. This will 'sandbox' them from the rest of the site. You can keep all the data in the database and all the user files in a user directory. The user can make subdirectories in the user directory. You can put some files in the user directory, mainly as a backup to the database, but if you have photo albums you might put album pages in it.

$usr_dir = "./User_Files/".$user_name;
$usr_path = "./User_Files/".$user_name."/";

It's important that everything be chmodded so that it can be deleted later if need be. In php you have to supply the full path to copy, chmod or move files