Web Hosting Talk







View Full Version : PHP mkdir();


Goldfiles
05-09-2006, 06:08 PM
$result = mkdir('downloads/newfolder', 0777);

That code SHOULD be chmoding the new folder to 777, but it is showing up as drw-rw-rw-

The folder above it is chmod 777.

What's up with this? Why isn't the chmod 0777 making the folder have full access? Is there something I am not seeing?

Goldfiles
05-09-2006, 06:23 PM
oh, and if i go into my ftp program, it shows up as drw-rw-rw- and i can change it to 777 via ftp, but everything needs to be handled by php. Why isn't the php script working?

gfxnetwork
05-09-2006, 07:35 PM
When creating that what are the permissions for the folder "downloads/"?

Have you tried to just created the folder and then use the chmod() code instead cause ive seen that way one some servers dont work. Just a thought.

Goldfiles
05-09-2006, 07:43 PM
The funny thing is, it worked last week! I have no idea why it stopped working.

It is supposed to chmod to 777 like the code says. But it is really chmoded to 666. I dont get it. I'll try your advice though.

Goldfiles
05-09-2006, 07:53 PM
answer found

$foo='my_directory';

$old_umask = umask(0);
mkdir($foo,0777); // the default chmod
umask($old_umask);

gfxnetwork
05-09-2006, 08:04 PM
cool, never used umask() function before but looks really handy, am sure it will come sometime in the future... good find.

RogueDogg
05-17-2006, 04:12 PM
gfxnetwork:

I was trying to make this exact script but I'm getting a permission error. Could I have a copy of your script ( minus your personal info ) and see if yours works? I'd appreciate it.