Hello - I have a form detailing info on a property, and i would like to add an image upload for multiple images, where it stores the image in a folder and the file name in a table - I have no clue what I am doing and totally new to php so please excuse my ignorance..
I have two tables, one for storing all the property details and the other for storing the files (this one has 13 columns, PropertyID, Photo1, Photo 2, and so on to Photo12)..
I have found the following script for storing one image, and have tried to alter to add extra (I need to store 12 images) but it keeps failing - can anyone help I am losing it big time?
form -
<form enctype="multipart/form-data" action="add.php" method="POST">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name = "email"><br>
Phone: <input type="text" name = "phone"><br>
Photo: <input type="file" name="photo"><br>
<input type="submit" value="Add">
</form>
add.php -
<?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'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$pic=($_FILES['photo']['name']);
// Connects to your Database
mysql_connect("your.hostaddress.com", "username", "password") or die(mysql_error()) ;
mysql_select_db("Database_Name") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
thanks for your time:-)