Creating directory

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
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Creating directory

Post by Shendemiar »

What directive controls if the php is allowed to create and delete directories?
liquid
Forum Newbie
Posts: 14
Joined: Thu Oct 21, 2004 2:19 pm
Location: Wyoming USA

Post by liquid »

Im not sure if this is what your looking for but

$someDirName=somedirname <--- can be given value dynamically if necessary.

Code: Select all

$pathname = "yourPath".$someDirName;

$old = umask(0);
mkdir($pathname, 0777);
chmod($pathname, 0777);
umask($old);
The above code should create the dir and give it proper permissions to write to it.

hope it helps a bit if not check out
http://www.php.net
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Thanks, but my problem is, that the abouve doesn't create anything. Must be some serverside setting...
liquid
Forum Newbie
Posts: 14
Joined: Thu Oct 21, 2004 2:19 pm
Location: Wyoming USA

Post by liquid »

The one thing you have to make sure of is that the intitial dir you are trying to create the new dir in, must be given full permissions. I had to connect through an ftp program and manually give the main dir full permissions then it seemed to work fine.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

Correct.

Now i can make dir's.

When i check them with ftp, permissions are just the same on php made and ftp made dirs, BUT

Those made with php i can't uplad anything via php, but those made with ftp i can upload via php. Via ftp both are uploadable.
liquid
Forum Newbie
Posts: 14
Joined: Thu Oct 21, 2004 2:19 pm
Location: Wyoming USA

Post by liquid »

Could you post some code so I can take a look at whats going on?

Im out today, but will reply more in the morning if you still need some help.

liquid
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

liquid wrote:Could you post some code so I can take a look at whats going on?

Im out today, but will reply more in the morning if you still need some help.

liquid

drwxrwxrwx 2 httpd customer 4096 Nov 12 02:22 phpmade_dir
drwxrwxrwx 2 jat**** jat***** 4096 Oct 14 06:17 ftp_made_dir

That's the problem...
Post Reply