views:

82

answers:

1

I have a user system where, when you register for an account, it's supposed to automatically create a new folder for you.

I've placed something along the lines of mkdir('./upload/' . $this->session->userdata('id'), 0, true) in my Register controller but to no avail.

Does anybody know how to get it to work?

A: 

Did you setup the correct permissions? Codeigniter, or any other PHP script, won't be able to create any files or directories when they're not allowed due to incorrect CHMOD values. A value of either 755 or 775 should do in most cases. You can change these values using either the command line or using an FTP application (most applications can do that). Also be sure that either the owner or group is set to the same user as your webserver is running (www-data in most cases).

Examples:

chmod -R 775 /var/www/username/codeigniterapp.com/some_dir

You can change the group/user with the "chown" command:

chown -R www-data:someuser /var/www/username/codeigniterapp.com/some_dir

Note that the -R flag tells the command to execute itself recursively. If you only want to change the permissions of the top level directory you can simply remove the -R flag.

Yorick Peterse