Old 10-22-2005   #1 (permalink)
Registered User
 
Join Date: Aug 2005
Posts: 15

Uploading Multiple Images into a Database

Hi guys,
I've been trying to write a script to upload multiple images and store them in a database. Pretty much, my form page asks for a text comment (in a textarea), and then up to 2 pictures. That form also features a hidden ID field. I was planning on storing all these into one row: id, text, pic1name, pic1, pic2name, pic2. However, I can't find a tutorial on doing this correctly, and my attempts to mix-and-match are not working. What can I do here?? Has anybody done this before and still have the code for me to take a look at? Please guys, I need some major help on this one...
ibanez270dx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 10-23-2005   #2 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
Code:
<?php

if(isset($_POST["submit"])){

mysql_connect...
mysql_select_db...

$uploaddir = $_SERVER["DOCUMENT_ROOT"];

foreach($_FILES["pics"]["name"] as $key => $current){

$uploadfile = $uploaddir . basename($current);

if (!move_uploaded_file($_FILES["pics"]["tmp_name"][$key], $uploadfile)) {
   echo "{$current} uploading failed.";
}

}

mysql_query("INSERT INTO Table(Text, Pic1, Pic2) VALUES('".$_POST["text"]."','".$_FILES['pics']['name'][0]."','".$_FILES['pics']['name'][1]."')") or die(mysql_error());

echo "<p>Files uploaded successfully</p>";

} else {

?><form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" enctype="multipart/form-data">
<input type="file" name="pics[]" /> Pic 1<br />
<input type="file" name="pics[]" /> Pic 2<br />
<textarea name="text" rows="10" cols="20">text</textarea><br />
<input type="submit" name="submit" value="enter" />
</form>
<?php

}

?>
try something like that, that uses html arrays instead of seperate file variables. if that doesn't work it shouldn't take much tweaking to get working (i haven't tested that).
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 10-23-2005   #3 (permalink)
Invicible Snake
 
ParaSnake's Avatar
 
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668

Send a message via MSN to ParaSnake Send a message via Yahoo to ParaSnake
This is what you may do :
- Create ur table,make the "id" become "auto_increment"
- Check out this to make sure u get rid of upload multiple files : http://www.php.net/manual/en/feature...d.multiple.php
- write ur scripts to upload,now u dont have to have a hidden ID,because it increase automatically in step 1
- after the scripts done uploading,extract the urls from 2 images that have been uploaded before(use PHP string functions)
- write all u need to the database (comment,pic1 url,pic1,pic2 url,pic2)

In case u meaned upload images into database,i have no idea because i`ve never do such things,but it's able to do it
-
__________________
ParaSnake is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 10-23-2005   #4 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ to scrowler
oh, if you meant upload images into the database, you need to get the file data into a string, put it in the database, then make a script to turn it back into a file when finished.

see this tutorial.
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying Fake Images Man1c M0g Announcements 0 08-24-2005 10:16 PM
Overlapping Images: Putting images on top of another jasonchan483 Adobe Photoshop 5 07-30-2005 11:29 AM
Making a single loop .gif play multiple times GoldNetX HTML / PHP / ASP / JS 4 07-25-2005 12:26 PM
Movie Database... Bub HTML / PHP / ASP / JS 3 04-05-2005 07:27 PM
blending two external images into each other LimitLess Flash & Dynamic Media 20 07-04-2004 07:53 PM


All times are GMT +1. The time now is 06:05 PM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT