Having Problem in uploading Image.....Please help

Hi There,

I am newbie in php, and having problem with uploading image in php and I have to edit someone’s code so its little complicated.

Please have a look


if ($HTTP_POST_FILES['enlarge3']['name'] != "") {			
			$photo_name = post_img($HTTP_POST_FILES['enlarge3']['name'], $HTTP_POST_FILES['enlarge3']['tmp_name'],"../userimages");
			$sql = "insert into tbl_photo(userid,photo) values('$userid','$photo_name')";
			$imgRes = Execute($sql);
		}

What I think is, $HTTP_POST_FILES is not supported in my local host, Is there something I need to do it as It working perfectly when I am trying this.


$spth = "../userimages/".$_FILES['enlarge1']['name'];			
			if(copy($_FILES['enlarge1']['tmp_name'],$spth))
			{
			$photo_name = "../userimages".$_FILES['enlarge1']['name'];
			$photo_name1 = $_FILES['enlarge1']['name'];
			$sql = "insert into tbl_photo(userid,photo) values('$userid','$photo_name')";
			$imgRes = Execute($sql);
		
			
			}
			else
			{
				echo 'Error: cant upload';
				die;
			}

thanks for your help.

Hi Danish,

It looks like you’ve answered your own question there. $HTTP_POST_FILES is the old name that PHP used to reference the global array of uploaded files, but it was deprecated in PHP 4.1 and, as you’ve discovered, is replaced by $_FILES: http://www.php.net/manual/en/reserved.variables.files.php