|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-03-23 14:36 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 17:00:01 2025 UTC |
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