Folder permissions and PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bos45430
Forum Newbie
Posts: 12
Joined: Sun Jul 08, 2007 11:11 am

Folder permissions and PHP

Post by bos45430 »

When my users create an account, my code creates personal folders for them.

$currentdir=getcwd();
$savedir="$currentdir/users/$_COOKIE[username]/albums/$_POST[albumname]";
mkdir($savedir,0777);

BUT it isnt creating the folders with a 777 permission. Its a Linux server running Apache. How can I make my script create the folders with 777 chmod by default?

Any help greatly appreciated

john
dirkr
Forum Newbie
Posts: 20
Joined: Sat Jul 07, 2007 2:55 pm

Post by dirkr »

not sure but you can always try taking a look at the chmod function ( not sure if that works on folder too )
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

if $currentdir = 'foo' the value of $savedir after the assignment is:

Code: Select all

foo/users/Array[username]/albums/Array[albumname]
Read the PHP manual on strings, in particular variable substitution in double quoted strings.
Post Reply