Jump to content

Image upload issue


tutorialstuff

Recommended Posts

I have a script that I thought was working just fine but it appears to be only working in firefox and not IE. Can anybody take a look at it and tell me if there's anything there that would cause it not to work in IE?

 

Thanks! - Mike

 

<?php
include('../site_files/includes/constants.php');


function save_image($file, $id, $sizex, $sizey, $pre){
global $image_path;
$image=$file['name'];
$userfile_tmp = $file['tmp_name'];
$userfile_size = $file['size'];
$userfile_type = $file 	['type']; 
if($image){
	if($userfile_type == "image/jpg" || $userfile_type == "image/jpeg" || $userfile_type == "image/png" || $userfile_type == "image/gif"){
		$max_x = $sizex;
		$max_y = $sizey;
		if ($userfile_type == "image/jpg" || $userfile_type == "image/jpeg"){
			$img = imagecreatefromjpeg($userfile_tmp);
		}elseif ($userfile_type == "image/gif"){
			$img = imagecreatefromgif($userfile_tmp);
		}elseif ($userfile_type == "image/png"){	
			$img = imagecreatefrompng($userfile_tmp);
		}else{
			print "didn't work";
		}
		$imagex = imagesx($img);
		$imagey = imagesy($img);
		$dim = max($imagex/$max_x, $imagey/$max_y);
		$nx = $imagex/$dim;
		$ny = $imagey/$dim;
		$image = imagecreatetruecolor($nx, $ny);
		if ($userfile_type == "image/jpg" || $userfile_type == "image/jpeg"){
			imagecopyresampled($image, $img, 0, 0, 0, 0, $nx, $ny, $imagex, $imagey);
			$image_path = '<img src="http://techguymike.com/window/images/uploads/'.$pre.$id.'.jpg" />';
			return imagejpeg($image, '../images/uploads/'.$pre.$id.'.jpg');
		}elseif($userfile_type == "image/gif"){
			//change the RGB(255, 255, 255) to change background color fill
			$background_color = imagecolorallocate($image, 255, 255, 255);
			imagefill($image, 0, 0, $background_color);
			imagecopyresampled($image, $img, 0, 0, 0, 0, $nx, $ny, $imagex, $imagey);
			$image_path = '<img src="http://techguymike.com/window/images/uploads/'.$pre.$id.'.gif" />';
			return imagegif($image, '../images/uploads/'.$pre.$id.'.gif');
		}elseif ($userfile_type == "image/png"){
			//change the RGB(255, 255, 255) to change background color fill
			$background_color = imagecolorallocate($image, 255, 255, 255);
			imagefill($image, 0, 0, $background_color);
			imagecopyresampled($image, $img, 0, 0, 0, 0, $nx, $ny, $imagex, $imagey);
			$image_path = '<img src="http://techguymike.com/window/images/uploads/'.$pre.$id.'.png" />';
			return imagepng($image, '../images/uploads/'.$pre.$id.'.png'); 
		}
		//return $image_path;
	}
}
}
?>
<?php 
if (isset($_POST['submit'])=='submit'){
if(isset($_FILES['image']) && $_FILES['image']['name'] != ''){
	save_image($_FILES['image'], 14, 250, 300, front);
	$image_front = $image_path;
}else{
	print "didn't work";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<form action="image-upload.php" method="post" enctype="multipart/form-data">
	<table class="announcement-form" cellspacing="0">
		<tr>
						<th>Image</th>
			<td><input type="file" name="image" id="image" size="65" /></td>
		</tr>
		<tr>
			<th> </th>
			<td><input type="submit" name="submit" value="submit" /></td>
		</tr>

	</table>
</form>




</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/94601-image-upload-issue/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.