View Full Version : Upload to different directories

05-05-2006, 10:37 PM
hi guys..

I have an upload script on my site, for users to upload images to the gallery...



if (is_uploaded_file($_FILES['file']['tmp_name']))
print "Image Uploaded Successfully"


I have 3 gallerys and each have 2 directories. The above script upoads to both gallery and largegallery. Or so it should lol

What im after is on the form to have a drop down list that says select gallery to upload the image to....

and then whichever option the user selects it will upload the image to the 2 directories relevent to that gallery.

Is this possible?

Thanks in advance


05-05-2006, 10:58 PM
If you give the form fields names of uploaddir and uploaddirl and are using method="post" then the fields will be available to the script as $_POST['uploaddir'] and $_POST['uploaddirl'] so you can then use those fields in your code to determine the directory (after validating their contents to make usre someone hasn't hacked your form in an attempt to use the fields for something else).

05-05-2006, 11:11 PM
i have just checked that script and it doesent work :(

well it does, but it only uploads to $uploaddir and not to u$uploaddirl

This is my form:

<form action="upload.php" method="post" enctype="multipart/form-data">
<div id="form">
<label class="boldital" for="file">Image:</label>
<input type="file" name="file" id="file">
<input type="submit" id="upload" name="upload" value="Upload">

My galleries are as follows:

Pool - pool_gallery
------ pool_largegallery

Skating - skating_gallery

Random - gallery

Thats it basically, i think i understand tha basics of what you mean, but i may be wrong and actually understand none of it!! lol

i know i will need to put an option in the form to select the gallery name, then set the option to the variable that contains that relevent gallery name?

Am i on the right track?

thanks again


05-06-2006, 04:28 PM
anyone got any ideas?

the only idea i can think of is writing 3 different scripts maybe? but then how do i change the form action depending on option selected.??