Page 1 of 1

Create folder/directory

Posted: Mon Dec 06, 2004 2:51 pm
by jrcal
I searched the forum for this but was unable to find anything - so I hope I'll have more luck with this post.

I am just starting to program with PHP, and I was wondering if there was any PHP script or function that I could use either to create folders/directories on my Linux server, or create new html files on my server.

For example, say I wanted to create a folder named news or events - I would want to type it in through a form and click "Create" - and have it create that new folder/directory.

Thanks! :)

Posted: Mon Dec 06, 2004 3:09 pm
by dull1554
[php_man]
mkdir
Makes directory (PHP 3, PHP 4 )
bool mkdir ( string pathname [, int mode] )

Attempts to create the directory specified by pathname.

Note that you probably want to specify the mode as an octal number, which means it should have a leading zero. The mode is also modified by the current umask, which you can change using umask().

Note:
Mode is ignored on Windows, and became optional in PHP 4.2.0.

The mode is 0777 by default, which means the widest possible access. For more information on modes, read the details on the chmod() page.

copy to clipboard
<?php
mkdir ("/path/to/my/dir", 0700);
?>
Returns TRUE on success or FALSE on failure.

See also rmdir().
[/php_man]

Posted: Mon Dec 06, 2004 3:14 pm
by potsed

Posted: Mon Dec 06, 2004 3:19 pm
by jrcal
Wonderful. These are great!

Thanks guys!