I'll post the entire page that I'm working on, and the index file I'm copying is from the same directory as this file; so I assumed that should work, correct me if I'm wrong.
<?php
// set our absolute path to the directories will be created in:
$path = $_SERVER['DOCUMENT_ROOT'] . '/albums/';
if (isset($_POST['create'])) {
// Grab our form Data
$dirName = isset($_POST['dirName'])?$_POST['dirName']:false;
// first validate the value:
if ($dirName !== false && preg_match('~([^A-Z0-9]+)~i', $dirName, $matches) === 0) {
// We have a valid directory:
if (!is_dir($path . $dirName)) {
// We are good to create this directory:
if (mkdir(!$path . $dirName, 0775)) {
$success = "Your directory has been created succesfully!<br /><br />";
}else {
$error = "Unable to create dir {$dirName}.";
}
}else {
$error = "Directory {$dirName} already exists.";
}
}else {
// Invalid data, htmlenttie them incase < > were used.
$dirName = htmlentities($dirName);
$error = "You have invalid values in {$dirName}.";
}
}
?>
<?php
if (isset($_POST['create'])) {
$file = 'index.html';
$newfile = ($dirName . 'index.html');
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
}
?>
<html>
<head><title>Make Directory</title>
<style type="text/css">
a:link {
COLOR: #fff;
}
a:visited {
COLOR: #fff;
}
a:hover {
COLOR: #fff;
}
a:active {
COLOR: #fff;
}
</style>
<script type="text/javascript">
function delayedRedirect(){
window.location = "/default.aspx"
}
</script>
</head>
<body text="#FFFFFF">
<center><?php echo (isset($success)?"<h3>$success</h3>":""); ?>
<h2><font color="black">Add your name & pics</font></h2>
<?php echo (isset($error)?'<span style="color:red;">' . $error . '</span>':''); ?>
<form name="phpMkDIRForm" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<font color="black">Enter Your Name (No Spaces or Symbols):<BR> <input type="text" value="" name="dirName" /><br />
<input type="submit" name="create" value="Add Pics" />
</form></center>
</body></font>
</html>