Multiple upload assigning specific names

Reply

Join Date: Oct 2008
Posts: 8
Reputation: twmprys is an unknown quantity at this point 
Solved Threads: 0
twmprys twmprys is offline Offline
Newbie Poster

Multiple upload assigning specific names

 
0
  #1
Oct 13th, 2008
Hello, hope someone can help. I've created a simple interface for a website owner to carry out very limited editing. On the first page, there's a form which uploads just one picture to a picture folder and inserts text into a database field. That works fine. Now I need to create a new page with a form where you can choose four pictures with corresponding text. The text works OK, that just inserts into four separate fields in a database. I hoped I could simply duplicate the picture upload script (changing the input names each time), but it doesn't work. (Please note that the pictures have to overwrite existing ones, so they appear on the website - that's is why I specify the precise path).

This is the picture input script:
move_uploaded_file($_FILES['pic1']['tmp_name'], 'pics/picture.jpg');

Repeating this three times (with pic2, pic3, pic4) doesn't seem to work.
Any ideas?
Last edited by twmprys; Oct 13th, 2008 at 6:35 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,479
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 136
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: Multiple upload assigning specific names

 
0
  #2
Oct 13th, 2008
move_uploaded_file($_FILES['pic1']['tmp_name'], 'pics/picture.jpg');

Repeating this three times (with pic2, pic3, pic4) doesn't seem to work.
The reason why that didn't work is because the array ['pic1'] refers the the name of the file browse field in your html form. So what you put in 'pic1' should be the same as what you put in the type='file' field. This then brings the question of how to load the image multiple times. To solve the issue of loading the file multiple times, use the following code:
  1. <?
  2. $image=imagecreatefromjpeg($_FILES['uploadedfile']['name']);
  3. ?>
Then the image is stored in the variable $image where it can be used by the gd library. Note you may want to alter the imagecreatefrom*() to the appropriate supported format.
Last edited by cwarn23; Oct 13th, 2008 at 8:21 am. Reason: code tags
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 8
Reputation: twmprys is an unknown quantity at this point 
Solved Threads: 0
twmprys twmprys is offline Offline
Newbie Poster

Re: Multiple upload assigning specific names

 
0
  #3
Oct 13th, 2008
Thank you for this, but I'm not loading the same image more than once - there are four different images to be loaded, they just overwrite existing images. There are four fields in the form for the images: pic1, pic2, pic3 and pic4. None of them are being passed up to the site, whereas there isn't a problem with the form with just one image.

Originally Posted by cwarn23 View Post
The reason why that didn't work is because the array ['pic1'] refers the the name of the file browse field in your html form. So what you put in 'pic1' should be the same as what you put in the type='file' field. This then brings the question of how to load the image multiple times. To solve the issue of loading the file multiple times, use the following code:
  1. <?
  2. $image=imagecreatefromjpeg($_FILES['uploadedfile']['name']);
  3. ?>
Then the image is stored in the variable $image where it can be used by the gd library. Note you may want to alter the imagecreatefrom*() to the appropriate supported format.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC