I have written the following image upload code:
image_upload.html:
<html>
<head>
</head>
<body>
<form method="post" action="check_image.php" enctype="multipart/form-data">
<table border="0" cellpadding="5">
<tr>
<td>Image title or caption</td>
<td><input name="image_caption" type="text" id="image_caption" size="55" maxlength="255" /></td>
</tr>
<tr>
<td>Your user name:</td>
<td><input name="image_username" type="text" id="image_username" size="55" maxlength="255" /></td>
</tr>
<tr>
<td>Upload image:</td>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<td><input name="image_filename" type="file" id="image_filename"></td>
</tr>
</table>
<br>
<p align="center"><input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Clear Form">
</p>
</form>
</body>
</html>
check_image.php:
<?
include('../functions.php');
mysql_connect("loaclhost","username","password")
or die("Failure to communicate");
mysql_select_db("db")
or die("Could not connect to Database");
$image_caption = $_POST['image_caption'];
$image_username = $_POST['image_username'];
$image_caption = $_FILES['image_filename']['name'];
$today = date("Y-m-d");
$ImageDir = "D:/uploads/";
$ImageName = $ImageDir . $image_tempname;
if(move_uploaded_file($_FILES['image_filename']['tmpname'],$ImageName)){
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";}}
print_r($_FILES);
?>
And its giving the following output:
Array ( [image_filename] => Array ( [name] => little-baby-monkeys.jpg [type] => image/pjpeg [tmp_name] => C:\PHP\uploadtemp\php1839.tmp [error] => 0 [size] => 105075 ) )
Can anyone please help me? its urgent..