Jump to content

multi-Image upload


emediastudios

Recommended Posts

Hi all.

I have a code that works fine except for one thing, it only uploads (1) image and i want to upload (4).

the code i have does all ehat i want and inserts the file name in to my SQL database along with some other info.

Can someone tell me how to alter my code to upload (4)images, and record there image name into sql.

the code i have below i altered to process (3) pics but it doesnt upload the images and  only inserts there image file name into sql.

 

 

Thanks so much........... ;)

Heres the code i have

 

<?php

 

//This is the directory where images will be saved

$target = "../images/";

$target = $target . basename( $_FILES['photo']['name']);

 

 

//This gets all the other information from the form

$name=$_POST['name'];

$suburb=$_POST['suburb'];

$price=$_POST['price'];

$content=$_POST['content'];

$pic=($_FILES['photo']['name']);

$pic2=($_FILES['photo2']['name']);

$pic3=($_FILES['photo3']['name']);

 

 

// Connects to your Database

mysql_connect("localhost", "root", "5050888202") or die(mysql_error()) ;

mysql_select_db("gcproperty") or die(mysql_error()) ;

 

//Writes the information to the database

mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$pic', '$pic2', '$pic3')") ;

 

//Writes the photo to the server

if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))  --------------My problem needs to sorted here somewhere i think.

{

 

//Tells you if its all ok

print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">";

}

else {

 

//Gives and error if its not

echo "Sorry, there was a problem uploading your file.";

}

?>[/color]

 

 

Link to comment
https://forums.phpfreaks.com/topic/70587-multi-image-upload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.