please i need help on this code.the code is made of an html which uploads image and a php script which displays the image and its size.my problem is from the php code;it doesn't displays the image after upload using the html .pls i ll appreciate an elaborate discussion hilie i show the code.
1.the html code
html>
<head>
<title>Upload your pic to our site!</title>
</head>
<body>
<form name="form1" method="post" action="check_image.php"
enctype="multipart/form-data">
<table border="0" cellpadding="5">
<tr>
<td>Image Title or Caption<br>
<em>Example: You talkin' to me?</em></td>
<td><input name="image_caption" type="text" id="item_caption" size="55"
maxlength="255"></td>
</tr>
<tr>
<td>Your Username</td>
<td><input name="image_username" type="text" id="image_username" size="15"
maxlength="255"></td>
</tr>
<td>Upload Image:</td>
<td><input name="image_filename" type="file" id="image_filename"></td>
</tr>
</table>
<br>
<em>Acceptable image formats include: GIF, JPG/JPEG, and PNG.</em>
<p align="center"><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Clear Form">
</p>
</form>
</body>
</html>
2.the php code
<?php
//connect to the database
$link = mysql_connect("localhost", "root", "password")
or die("Could not connect: " . mysql_error());
mysql_select_db("moviesite", $link)
or die (mysql_error());
//make variables available
$image_caption = $POST['image_caption'];
$image_username = $POST['image_username'];
$image_tempname = $_FILES['image_filename']['name'];
$today = date("Y-m-d");
//upload image and check for image type
//make sure to change your path to match your images directory
$ImageDir ="C:/wamp/www/phphr/Clips";
$ImageName = $ImageDir.$image_tempname;
if (move_uploaded_file($_FILES['image_filename']['tmp_name'],$ImageName)){
//get info about the image being uploaded
list($width, $height, $type, $attr) = getimagesize($ImageName);
switch ($type) {
case 1:
$ext = ".gif";
break;
case 2:
$ext = ".jpg";
break;
case 3:
$ext = ".png";
break;
default:
echo "Sorry, but the file you uploaded was not a GIF, JPG, or " .
"PNG file.<br>";
echo "Please hit your browser's 'back' button and try again.";
}
//insert info into image table
$insert = "INSERT INTO images
(image_caption, image_username, image_date)
VALUES
('$image_caption', '$image_username', '$today')";
$insertresults = mysql_query($insert)
or die(mysql_error());
$lastpicid = mysql_insert_id();
$newfilename = $ImageDir.$lastpicid.$ext;
rename($ImageName,$newfilename);
}
?>
<html>
<head>
<title>Here is your pic!</title>
</head>
<body>
<h1>So how does it feel to be famous?</h1><br><br>
<p>Here is the picture you just uploaded to our servers:</p>
<img src="Clips/<?php echo $lastpicid.$ext; ?>" align="left">
<strong><?php echo $image_caption; ?></strong><br>
This image is a <?php echo $ext; ?> image.<br>
It is <?php echo $width; ?> pixels wide
and <?php echo $height; ?> pixels high.<br>
It was uploaded on <?php echo $today; ?>.
</body>
</html>