Forum Moderators: coopster

Message Too Old, No Replies

If directory doesn't exist mkdir

Is this possible to do?

         

scraptoft

5:37 pm on May 21, 2007 (gmt 0)

10+ Year Member



Good evening WW,

I am hoping this is A) possible and B) easy enough to do.

I am trying to check if a directory exists - if it doesn't I want to make it by using mkdir.

Is this possible? I am still learning and havn't came across working with directories before.

I have searched but not found anything yet except the mkdir() command which I thought was very useful.

dreamcatcher

7:02 pm on May 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi scraptoft,

You need the is_dir function.

if (!is_dir [uk.php.net]('dir'))
{
mkdir('dir');
}

Or you can use file_exists [uk3.php.net]

dc

scraptoft

8:34 am on May 22, 2007 (gmt 0)

10+ Year Member



Thank you for your time Dreamcatcher it looks easy enough. I will have a read into those functions right now.

Edit: Works perfectly :-D