Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Upload - into specific folders based on drop-down selection

Status
Not open for further replies.

dreamaz

Technical User
Dec 18, 2002
184
CA
Hi,

I have a simple script to upload files which works fine, but i wanted to add a drop down with categories and based on that, the file gets uploaded to that folder.

Here's what i have for the form:

form action="uploader.php" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" />
Select a folder:
<select name="select" id="select">
<option value="802.11">802.11</option>
<option value="RIM">RIM</option>
</select>
<br />
<input type="submit" value="Upload File" />
</form>

And i have this as the uploader.php script:

<?php
$FOLDER = $_GET['select'];
// Where the file is going to be placed
$target_path = "/var//* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

// This is how we will get the temporary file...
$_FILES['uploadedfile']['tmp_name'];

$target_path = "/var/
$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!";
}
?>

This doesn't seem to work, i guess im not passing the drop down selection data into the variable on the uploader.php file OR im not calling the right _GET variable to get that data

Any help is apprecaited

Thanks

dR
 
First of all your forms method is [red]POST[/red]
$_GET['select'] does not exist, it should be $_POST['select'].

Try that and see if it works.

Also yuou should try to echo your $FOLDER variable just to check it has a the proper content in it.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top