i used this code to upload images and display from database but not working correctly...
images.php
<?php
include('header.php');
?>
<center>
<form action="addimages.php" method="post" enctype="multipart/form-data">
<table border=0>
<tr><td>Select Image: </td><td><input type="file" name="image"></td></tr>
<tr><td>Caption: </td><td><input name="caption" type="text"></td></tr>
<tr> <td colspan=2><input type="submit" name="Submit" value="Upload" ></td></tr>
</table>
</form>
</center>
Photo Gallary:
<br />
<br />
<?php
$result = mysql_query("SELECT * FROM images ORDER BY imgid");
while($row = mysql_fetch_array($result))
{
echo "<div class='img'>";
echo "<a target='_blank' href=".$row['location'].">";
echo "<img src=".$row['location']." width='110' height='120'>";
echo "</a>";
echo "<div class='desc'>".$row['caption'];
echo "<br/>";
echo "<a href=\"javascript:delimg('$row->imgid','$row->caption');\">Delete image</a></td>";
echo "<form method ='POST' action='dimg.php'><input type='submit' value='delete'name='delete'></form>";
echo "</div>";
echo "</div>";
}
echo "</table>";
?>
<?php
include('footer.php');
?>
addimages.php
<?php
require('../includes/config.php');
if (!isset($_FILES['image']['tmp_name'])) {
echo "";
}else{
$file=$_FILES['image']['tmp_name'];
$image= addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name= addslashes($_FILES['image']['name']);
move_uploaded_file($_FILES["image"]["tmp_name"],"../images/" . $_FILES["image"]["name"]);
$location="../images/" . $_FILES["image"]["name"];
$caption=$_POST['caption'];
$save=mysql_query("INSERT INTO images (caption, location) VALUES ('$caption','$location')");
header("location: gallarymanager.php");
exit();
}
?>
some images are displayed and some blank image fields....