I have some code which uploads one image into one row. I am now trying to adapt it so that it uploads multiple images.
However it currently uploads one image into the same rows "image, imageone". Although Im also confused how to upload multiple images and move onto the next empty row. Any suggestions please?
<div class="imageuploadarea">
<div class="imageuploadinfo">
Select a JPG, GIF, PNG or TIF File:
</div>
<?php // upload.php
echo <<<_END
<div class="user-area">
<form method='post' action='upload.php' enctype='multipart/form-data'>
<input type='file' name='filename' class="browse" />
<input type="submit" value="Upload" class="submit-button" />
</div>
</form>
<div class="user-area">
<form method='post' action='upload.php' enctype='multipart/form-data'>
<input type='file' name='filename' class="browse" />
<input type="submit" value="Upload" class="submit-button" />
</div>
</form>
</div>
_END;
if ($_FILES)
{
$name = $_FILES['filename']['name'];
switch($_FILES['filename']['type'])
{
case 'image/jpeg': $ext = 'jpg'; break;
case 'image/gif': $ext = 'gif'; break;
case 'image/png': $ext = 'png'; break;
case 'image/tiff': $ext = 'tif'; break;
default: $ext = ''; break;
}
if ($ext)
{
$n = uniqid().".$ext";
move_uploaded_file($_FILES['filename']['tmp_name'], "images/".$n);
}
else echo "The image must be a jpeg, gif, png or tiff file format.";
}
else echo "No image has been uploaded";
$sql = "UPDATE users SET logo = '". mysql_real_escape_string($n) ."' WHERE id='".$_SESSION['userID']."'";
$sql1 = "UPDATE users SET logoone = '". mysql_real_escape_string($n) ."' WHERE id='".$_SESSION['userID']."'";
if ($n <> "") {
$result = mysql_query($sql) or die("MySQL Error" . mysql_error());
$result = mysql_query($sql1) or die("MySQL Error" . mysql_error());
}
?>












