I am trying to come up with a statement that will create a directory using an ID# that is passed to this page, but if the directory with the ID# has already been made then just upload to that directory. Does anyone know how to do this?
//Creates ID folder in the upload directory
$resourcefolder = "photos/";
$filestocopy = "array";
$filestocopy[0] = "file1.php";
$filestocopy[1] = "file2.php";
$foldername = "(". $_REQUEST['ID'] .")";
mkdir ("photos/$foldername", 0777);
chmod ("photos/$foldername", 0777);
$link = mysql_connect("localhost", "db_name", "db_password") or die("Could not connect to server!");
$sql=mysql_query("INSERT INTO folders ('" . $foldername . "') VALUES ('" . $foldername . "')");
{
$frompath = $resourcefolder.$filestocopy;
$topath = $resourcefolder.$foldername."/".$filestocopy;
if(copy($frompath, $topath)){
echo "Directory Created and files copied!";
} else {
echo "An error occured!";
}
}