Create a Directory
How do you create a directory using PHP?
This example will show you how you create a Directory using PHP.
This is useful in situations like f.ex if you have a site where people can become members of a kind. Then it could be that you want the users to have their own directory, for images, configs and other files. So you will have to create a directory on the fly, right?
This short example shows you how to do just that, using PHP.
On the HTML tab you have though some forms, so your users can name the directory them self.
If you will use this for the first scenario then you will use the PHP snippet. Just change the directory names and fire the PHP code in some other way.
HTML
<HTML><BODY>
<TABLE>
<FORM METHOD='POST' ACTION=''>
<TR>
<TD>Give your directory a name</TD>
<TD><INPUT TYPE='text' NAME='dirname'></TD>
</TR>
<TR>
<TD>Click here to create directory: </TD>
<TD><INPUT TYPE='submit' NAME='doit' VALUE='Create directory'></TD>
</TR></FORM>
</TABLE>
</BODY></HTML>
PHP
<?php
if (isset($_POST['doit'])) {
$dirname = $_POST['dirname'];
$stien = getcwd();
mkdir ($stien . "/" . $dirname);
echo "Okay, directory: " . $stien . "/" . $dirname . " have been created"; exit();
}
?>