From:             challa_amar at yahoo dot com
Operating system: Windows XP
PHP version:      5.1.2
PHP Bug Type:     *General Issues
Bug description:  Image upload problem

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 bug report at http://bugs.php.net/?id=36833&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=36833&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=36833&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=36833&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=36833&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=36833&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=36833&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=36833&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=36833&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=36833&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=36833&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=36833&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=36833&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=36833&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=36833&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=36833&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=36833&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=36833&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=36833&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=36833&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=36833&r=mysqlcfg

Reply via email to