Re: Choice of Upload destination Folder
Hi,
I spent the week-end pondering this issue as I felt there had to be a way to
do this simply.
I worked it out at 5.am this morning.................
The upload form: I called it uploadfiles.php as a test.
<form action="uploadedtofolder.php" method="post"
ENCTYPE="multipart/form-data">
<table width="80%">
<tr>
<td>File:
<input type="file" name="file" size="30"></td>
<td>Instruction here</td>
</tr>
<tr>
<td>Choose Folder:
<select name="folder">
<option value="option1">folderA
<option>
<option value="option2">folderB
<option>
<option value="option3">folderC
<option>
<option value="option4">folderD
<option>
<option value="option5">folderE
<option>
</select></td>
<td>Instruction</td>
</tr>
<tr>
<td><input type="submit" value="Upload!"></td>
<td>Press Upload.</td>
</tr>
</table>
</form>
The uploadedtofolder.php page:
<?php
$folder_name = $_POST["folder"] ;
switch ($folder_name) {
case "option1":
$uploaddir = "folderA/"; //Relevant path of the Folder
break;
case "option2":
$uploaddir = ""folderB/";
break;
case "option3":
$uploaddir = "folderC/";
break;
case "option4":
$uploaddir = "folderD/";
break;
case "option5":
$uploaddir = "folderE/";
break;
}
echo $uploaddir;
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['n
ame']);
}
print "Your File has been uploaded to the correct Folder!";
?>
This has worked a treat!
|