we put the site name twice...
<?
$site_name = $_GET['site']; //site name and folder being created
$target_path = "verifications/";
$newDir = $target_path . $site_name; //directory to go in
$makeDirectory = @mkdir($newDir, 0777);
$target_path1 = $newDir."/" . basename( $_FILES['up1']['name']);
if(move_uploaded_file($_FILES['up1']['tmp_name'], $target_path1))
{
print "Copied as : $target_path1";
}
?>
And here is another method, store the site names in database. If its already in the table, lets select its ID number, and put the files into that folder. It is a safer method.
<?php
$hostname='***'; //// specify host, i.e. 'localhost'
$user='****'; //// specify username
$pass='****'; //// specify password
$dbase='****'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
function check_data($content,$table,$field)
{
$sql="SELECT * FROM $table WHERE $field='".mysql_real_escape_string(stripslashes(trim($content)))."'";
if (mysql_num_rows(mysql_query($sql))>0)
{
$rows=mysql_fetch_assoc($result);
return($rows);
}
else
return(false);
}
function insert($content,$table,$field)
{
$sql="INSERT INTO $table ($field) VALUES ('".mysql_real_escape_string(stripslashes(trim($content)))."')";
$result=mysql_query($sql);
if($result)
return mysql_insert_id();
else
return false;
}
if(isset($_FILES) AND isset($_GET['site']))
{
$rows=check_data($_GET['site'],"site_names","Site_Name");
if($rows==false)
{
$id=insert($_GET['site'],"site_names","Site_Name");
mkdir("verifications/$id", 0777);
}
else
$id=$rows["id"];
print("The directory (ID) is $id<br>");
$target_path1 = "verifications/$id/" . basename( $_FILES['up1']['name']);
if(move_uploaded_file($_FILES['up1']['tmp_name'], $target_path1))
{
print "Copied as : $target_path1";
}
else
die("File upload Failed : $target_path1");
}
?>
And this query will make the Site names table, and you can store the site names in there!
Run that in phpmyadmin
CREATE TABLE `site_names` (
`id` int(6) NOT NULL auto_increment,`Site_Name` varchar(255) NOT NULL default ''
,PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1;