| | |
Multiple upload assigning specific names
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 8
Reputation:
Solved Threads: 0
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?
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.
•
•
•
•
move_uploaded_file($_FILES['pic1']['tmp_name'], 'pics/picture.jpg');
Repeating this three times (with pic2, pic3, pic4) doesn't seem to work.
php Syntax (Toggle Plain Text)
<? $image=imagecreatefromjpeg($_FILES['uploadedfile']['name']); ?>
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
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
•
•
Join Date: Oct 2008
Posts: 8
Reputation:
Solved Threads: 0
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.
•
•
•
•
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:
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.php Syntax (Toggle Plain Text)
<? $image=imagecreatefromjpeg($_FILES['uploadedfile']['name']); ?>
![]() |
Other Threads in the PHP Forum
- Previous Thread: Sessions: cookies and use_trans_sid
- Next Thread: Parse error: syntax error, unexpected $end in
| Thread Tools | Search this Thread |
ajax apache api array beginner beneath binary broadband broken button cakephp checkbox class cms code countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail match md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem protocol query radio random recursion regex remote script search server session sessions sms smtp soap source space sql strip_tags survey syntax system table tutorial undefined update upload url validator variable video virus votedown web window.onbeforeunload=closeme; xml youtube






