Hi all
I am having a bit of a problem trying to upload more than one picture to my database as well as some other fields.
I can get one picture to upload no problem, but am having no joy at all with more than one.
Could someone show where i put the relevant fields for this.
I assume that i need 3 path fields for 3 pictures and i would expect to call them path1, path2, and path3.
I am getting frustrated now, please help
<?
// you can change this to any directory you want
// as long as php can write to it
$uploadDir = 'pictures/';
if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$full = $_POST['full'];
$award = $_POST['award'];
$title = $_POST['title'];
$member = $_POST['member'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$price = $_POST['price'];
// the files will be saved in filePath
$filePath = $uploadDir . $fileName;
// move the files to the specified directory
// if the upload directory is not writable or
// something else went wrong $result will be false
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}
include 'library/config.php';
include 'library/opendb.php';
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO forsale (name, size, type, path, member, email, telephone, title, full, price) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$member', '$email', '$telephone', '$title', '$full', '$price' )";
mysql_query($query) or die('Error, query failed : ' . mysql_error());
include 'library/closedb.php';
echo "<br>File uploaded<br>";
$movedtolocation="pictures/".$_FILES['upload']['name'];# basically, take the location of wher the image is stored..
}
?>
<h2 align="center">Upload Your Picture </h2>
<form action="" method="post" enctype="multipart/form-data" name="uploadform">
<table width="456" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF" class="box">
<tr>
<td width="182"><p>Member Name:</td>
<td width="265"><p> <input name="member" type="text" size="35"></td>
</tr>
<tr>
<td><p>Member Email:</p></td>
<td><input name="email" type="text" id="email" size="35"></td>
</tr>
<tr>
<td><p>Telephone Number:</p></td>
<td><input name="telephone" type="text" id="telephone" size="35"></td>
</tr>
<tr>
<td><p>Advert Title:</p></td>
<td><input type="text" name="title" size="35"></td>
</tr>
<tr>
<td><p>Select Photograph to upload:</p></td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile" size="35"></td>
<tr>
<td><p>Full Description:</p>
<p class="small"><em>Note: These comments are limited to 2000 characters</em>)</p></td>
<td><textarea name="full" cols="45" rows="10" id="full"></textarea></td>
</tr>
<tr>
<td><p>Price:</p></td>
<td>£<input name="price" type="text" id="price" size="35"></td>
</tr>
<tr><td width="182"></td>
<td width="265"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
</tr>
</table>
</form>