Hi guys,
Got a problem uploading an image to a directory and then including that directory location into the database so that I can display the image.
Here is the code I have so far.
<div id="main_right">
<?php
if ($picture)
{
?>
<img src="<?php echo "../images/teacher_photo/" . $picture ?>" alt="<?php $picture ?>" height="200" width="200">
<?php
}
else
{
?>
<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><input type="submit" name="Submit" value="Upload" ></td></tr>
</table>
</form>
</div>
and the addimages.php page looks like this
<?php
include("db_connect.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/teacher_photo/" . $_FILES["image"]["name"]);
$location="../images/teacher_photo" . $_FILES["image"]["name"];
$sql_photo = "INSERT INTO `person` (photo) VALUES ('&location') WHERE person_id = " .$person_id;
$save = mysql_query($sql_photo,$conn);
echo "<script type=\"text/javascript\">window.location=\"admin.php\"</script>";
}
?>
So, any idea where I am going wrong?