php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36833 Image upload problem
Submitted: 2006-03-23 14:33 UTC Modified: 2006-03-23 14:36 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: challa_amar at yahoo dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.1.2 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: challa_amar at yahoo dot com
New email:
PHP Version: OS:

 

 [2006-03-23 14:33 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-23 14:36 UTC] tony2001@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 04:01:32 2024 UTC