i have 2 files related to this (from begining php5,apache,MySQL web development). first one is a html file which is below.
<html>
<head>
<title>Upload Pictures</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</th>
<em>Example:You talkin to me..</em></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="15" maxlengh="15"></td>
</tr>
<tr>
<td>Upload Image</td><td><input name="image_filename" type="file" id="image_filename"></td>
</tr>
</table>
<br>
<em>Acceptable image format :GIF,JPG or JPEG</em>
<p align="center" ><input type="submit" name="submit" value="Upload Now!">
<input type="reset" name="Submit2" value="clear all fields">
</p>
</form>
</body>
</html>
now my php file is below
<?php
$link=mysql_connect("localhost","user","pass") or die(mysql_error());
mysql_select_db("moviesite",$link) or die(mysql_error());
//$image_caption=$_POST['image_caption'];
//echo $image_caption;
//$image_username=$_POST['image_username'];
//echo $image_username;
$image_tempname=$_FILES['image_filename']['name'];
//echo $image_tempname;
$jimage=$_FILES['name'];
echo $jimage;
$today=date("Y-m-d");
//echo $today;
$ImageDir="D:/x/htdocs/wrox/afterchap6/images/";
//echo $ImageDir;
$ImageName=$ImageDir.$image_tempname;
echo $ImageName;
if(move_uploaded_file($_FILES['image_filname']['tmp_name'],$ImageName))
{
echo "The file ". basename( $_FILES['image_filename']['name']).
" has been uploaded";
}
else
{
echo "There was an error uploading the file, please try again!";
print_r($_FILES);
}
/*
if(move_uploaded_file($_FILES['image_filname']['tmp_name'],$ImageName))
{
//get info about image being uploaded
list($width,$height,$type,$attr)=getimagesize($Imagename);
switch ($type)
{
case 1:
$ext=".gif";
echo "gif";
break;
case 2:
$ext=".png";
echo ".png";
break;
case 3:
$ext=".jpg";
echo ".jpg";
break;
default:
echo "Sorry,but the file that you uploaded was not of GIF,JPEG or JPG or PNG format";
echo "Hit back button of your browser to upload again";
}}
$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 picture</title>
</head>
<body>
<br>
your image has been successfully uploaded;
</body>
</html>
-->
Problem is :it outputs the following message
D:/x/apache/images/beautiful-blue-bird-wallpaper-1600x1200.jpgThere was an error uploading the file, please try again!Array ( [image_filename] => Array ( [name] => beautiful-blue-bird-wallpaper-1600x1200.jpg [type] => image/jpeg [tmp_name] => D:\x\tmp\php16C.tmp [error] => 0 [size] => 190058 ) )
when i check to the images folder in the D:\x\htdocs\wrox\afterchap6\images\
no file is found.