And after uploading let's check the content types. Mime tipe check is a good solution to check the files from users!
Make an upload folder,
and into 1 and 2 named folder:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<?
if ($_FILES AND $_POST["selectfolder"])
{
$selectfolder=$_POST["selectfolder"];
switch ($selectfolder)
{
case "1":
$target_path = "uploads/1/";
break; //e --> 1.php
case "2":
$target_path = "uploads/2/";
break; //e --> 1.php
case "":
$target_path = "";
break; //e --> 1.php
}
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else
{
echo "There was an error uploading the file, please try again!";
}
}
?>
<form enctype="multipart/form-data" action="" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" />
<br>
<select name="selectfolder">
<option>Choose a folder</option>
<option value="1">Christmas</option>
<option value="2">New York</option>
</select>
<br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
www.phpcode.hu