Creating Folders/Directories

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
User avatar
kevin_javia
Forum Newbie
Posts: 15
Joined: Mon May 24, 2004 9:46 am
Location: India
Contact:

Creating Folders/Directories

Post by kevin_javia »

Greetings,

I am trying to create folders using my script.

Code: Select all

<?php
if (!is_dir("full/$uid"))
{
	$oldmask = umask(0); 
	mkdir("full/$uid",0777);
	umask($oldmask);
}
if (!is_dir("thumb/$uid"))
{
	$oldmask = umask(0); 
	mkdir("thumb/$uid",0777);
	umask($oldmask);
}
if (!is_dir("full/$uid/$c_id"))
{
	$oldmask = umask(0);
	mkdir("full/$uid/$c_id",0777);
	umask($oldmask);
}
if (!is_dir("thumb/$uid/$c_id"))
{
	$oldmask = umask(0); 
	mkdir("thumb/$uid/$c_id",0777);
	umask($oldmask);
}
?>
if $uid = 1 and $c_id = 2 are the values, folder "..../thumb/1" and folder "..../full/1" are created. But not " "..../full/1/1" and "..../thumb/1/1".
Here "full" and "thumb" both have 0777 chmod.

Script is giving error like mkdir(): SAFE MODE Restriction in effect.

What can be the problem? :?

Thanks for reading this far.

Kevin.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Trun off save mode in php.ini :)
User avatar
kevin_javia
Forum Newbie
Posts: 15
Joined: Mon May 24, 2004 9:46 am
Location: India
Contact:

Post by kevin_javia »

How can I do this using script?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

You cant.. you will have to edit php.ini

around line 160

; Safe Mode
;
safe_mode = Off
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

what about

Code: Select all

ini_set(SAFE_MODE, 0);
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

Phenom wrote:what about

Code: Select all

ini_set(SAFE_MODE, 0);
can only do that in php.ini







kevin_javia-
i ran into this problem too. you just simply cannot do what your trying to do if safe mode is on.

the only workaround i was able to do, was to use php's ftp functions to log into your own website, and either make the directories that way, or change the owner of the directories and the permissions too if neccesary.

ftp isnt very fast though, so if speed is very important, start looking for a solution to your problem that doesnt involve creating directorys on the fly which php must write to, or, get a host that doesnt use safemode.
Post Reply