1

Possible Duplicate:
PHP code mkdir('images','0777') creates a folder with 411 permissions! Why?

I am trying to create a folder on my server using php i have been trying this and it is not working it set it to 411 does anyone know why this is happening?

mkdir($create_path, "0777");

i have also tryed chmod but i am getting a safe mode error.

chmod($create_path, '0777');
Community
  • 1
  • 1
Rickstar
  • 6,057
  • 21
  • 55
  • 74
  • Also duplicate of http://stackoverflow.com/questions/4061224/php-mkdir-and-fopen-does-not-work-permissions-problem-umask-problem http://stackoverflow.com/questions/4061224/php-mkdir-and-fopen-does-not-work-permissions-problem-umask-problem http://stackoverflow.com/questions/4061224/php-mkdir-and-fopen-does-not-work-permissions-problem-umask-problem and others. – The Archetypal Paul Nov 09 '10 at 13:47

2 Answers2

7

Both chmod() and mkdir() accept an integer for $mode. It is easier to use octal numbers in that case:

mkdir('/path', 0777); // using octal
mkdir('/path', 511);  // same thing as previous but using decimal

Be careful and make sure you prepend your mode (i.e.: 777) with a 0 to tell the parser to use octal. Omitting the 0 will make it use decimal and will give a different result.

Since '0777' (string) is converted to decimal 777, it is not the same mode as 0777.

netcoder
  • 66,435
  • 19
  • 125
  • 142
1

Second parameter should be integer as you can see here. so use this one

mkdir($create_path, 0777); // it should works!

vaske
  • 9,332
  • 11
  • 50
  • 69