Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-05-2006, 10:37 PM   PM User | #1
jonnybinthemix
Regular Coder

 
Join Date: May 2006
Location: Bristol, UK
Posts: 147
Thanks: 6
Thanked 2 Times in 2 Posts
jonnybinthemix will become famous soon enough
Upload to different directories

hi guys..

I have an upload script on my site, for users to upload images to the gallery...
PHP Code:
<?php

$uploaddir
="gallery";
$uploaddirl="largegallery";

if (
is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddirl.'/'.$_FILES['file']['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

Jon
jonnybinthemix is offline   Reply With Quote
Old 05-05-2006, 10:58 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,468
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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).
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 05-05-2006, 11:11 PM   PM User | #3
jonnybinthemix
Regular Coder

 
Join Date: May 2006
Location: Bristol, UK
Posts: 147
Thanks: 6
Thanked 2 Times in 2 Posts
jonnybinthemix will become famous soon enough
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:

Code:
<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">
		<br>
		<br>
		<input type="submit" id="upload" name="upload" value="Upload">
	</div>
My galleries are as follows:

Pool - pool_gallery
------ pool_largegallery

Skating - skating_gallery
----------skating_gallerylarge

Random - gallery
----------gallerylarge


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

jon
jonnybinthemix is offline   Reply With Quote
Old 05-06-2006, 04:28 PM   PM User | #4
jonnybinthemix
Regular Coder

 
Join Date: May 2006
Location: Bristol, UK
Posts: 147
Thanks: 6
Thanked 2 Times in 2 Posts
jonnybinthemix will become famous soon enough
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.??
__________________
"You only live once, play it right, and once is enough" - me :)
"When i die only god can take my soul" - me again! :P
jonnybinthemix is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:39 AM.


Advertisement
Log in to turn off these ads.