#36833 [Opn->Bgs]: Image upload problem
| From: | tony2001@php.net | Date: | Thu, 23 Mar 2006 13:36:25 +0000 |
| Subject: | #36833 [Opn->Bgs]: Image upload problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-94812@lists.php.net to get a copy of this message | ||
ID: 36833
Updated by: tony2001@php.net
Reported By: challa_amar at yahoo dot com
-Status: Open
+Status: Bogus
Bug Type: *General Issues
Operating System: Windows XP
PHP Version: 5.1.2
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
Previous Comments:
------------------------------------------------------------------------
[2006-03-23 14:33:02] challa_amar at yahoo dot com
Description:
------------
Even though echo $_FILES['image_filename']['error']; is giving value as
0.The program is not entering into the follwing if loop...can u please
verify and get back to me
if
(move_uploaded_file($FILES['image_filename']['tmp_name'],$ImageName))
Reproduce code:
---------------
<?php
//connect to database
$link=mysql_connect("localhost","root","mysql")
or die("Could Not Connect:".mysql_error());
mysql_select_db("images",$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");
//ECHO "values";
//echo $_POST['image_caption'];
//echo $_POST['image_username'];
//ECHO $_FILES['image_filename']['name'];
Echo "Error display";
echo $_FILES['image_filename']['error'];
//upload image and check for image type
//C:\Documents and Settings\All Users\Documents\MyPictures\Sample
Pictures
//C:\WINDOWS\system32\inetsrv
//$ImageDir="C:/Documents and Settings/All Users/Documents/My
Pictures/Sample Pictures/";
$ImageDir="C:/PHP/uploadtemp/";
$ImageName=$ImageDir. $image_tempname;
//echo "testing";
//echo
move_uploaded_file($FILES['image_filename']['tmp_name'],$ImageName);
if
(move_uploaded_file($FILES['image_filename']['tmp_name'],$ImageName))
{
//get info of the image before being uploded
list($width,$height,$type,$attr)=getimagesize($ImageName);
ECHO "pARAMETRS";
ECHO $width;
ECHO $height;
ECHO $type;
ECHO $attr;
switch($type) {
case 1:
$ext=".gif";
break;
case 2:
$ext=".jpg";
echo "dfdsfdfss";
break;
default:
echo "Sorry,but the file you uploaded was not GIF,JPG or PNG
File.<br>";
echo "Please hit your browser back button and hit again";
}
//insert info into Image Table
$insert="INSERT INTO images
(image_caption,image_username,image_date)
VALUES
('$image_caption','$image_username','$today')";
$insertresults=mysql_insert_id();
$newfilename=$ImageDir.$lastpicid.$ext;
rename($ImageName,$newfilename);
}
?>
<html>
<head>
<title>Here Is Ur Pic</title>
</head>
<body>
<h1>So How does it feel to be famous</h1><br><br>
<p>here is the Picture U have Uploded to the servers:</p>
<img src="images/<?php echo $lastpicid .$ext; ?> align="left">
<strong><?php echo $image_name; ?></strong><br>
This Image is a <?php echo $ext; ?>image.<br>
It is <?php echo $height; ?> pixels wide
and <?php echo $height; ?> pixels high <br>
It was uploaded on <?php echo $today; ?>.
</body>
</html>
Expected result:
----------------
Should display the result with the Image
Actual result:
--------------
There is no result as the file is not uploaded
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36833&edit=1