emediastudios Posted September 25, 2007 Share Posted September 25, 2007 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] Quote Link to comment Share on other sites More sharing options...
fenway Posted September 25, 2007 Share Posted September 25, 2007 I don't see that function, I don't see tmp_name, and don't see you doing it 3 times. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.