Problem Displaying Images in Firefox, Safari (Works in IE)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello:

Maybe someone can help me with this.  I'm providing my site the
ability to upload images.  But the code I'm using will only display
the images in IE.  Firefox and Safari don't show anything.  Anyone
have any ideas why?


function uploadTemp()
{
       $uploaddir = getcwd()."/tmp_images/";
       $uploadfile = $uploaddir .
basename($_FILES['uploadheadshot']['name']);
       move_uploaded_file($_FILES['uploadheadshot']['tmp_name'],
$uploadfile);

			$fileName = $_FILES['uploadheadshot']['name'];
			$fileSize = $_FILES['uploadheadshot']['size'];
			$fileType = $_FILES['uploadheadshot']['type'];

			$fp      = fopen($uploadfile, 'r');
			$content = fread($fp, filesize($uploadfile));
			fclose($fp);

			//Now before we return it lets resize it if necessary
			$ht = $_REQUEST["height"];

			if(strlen($ht) > 0)
			{
				$im = imagecreatefromstring($content);
				$width = imagesx($im);
            	$height = imagesy($im);

            	if((int)$height > (int)$ht)
            	{
					// Set thumbnail-height to what as passed in
					$imgh = (int)$ht;
 					// calculate thumbnail-height from given width to maintain
aspect ratio
      				$imgw = $width / $height * $imgh;
      				// create new image using thumbnail-size
      				$thumb=imagecreatetruecolor($imgw,$imgh);
      				// copy original image to thumbnail
      			
imagecopyresampled($thumb,$im,0,0,0,0,$imgw,$imgh,ImageSX($im),ImageSY($im));

					header("Content-Type: {$fileType}");
    				// Output the image
   					imagejpeg($thumb,NULL,100);
   					imagedestroy($thumb);
   					return;
				}
			}

			if (!empty($content))
  			{
    			// Output the MIME header
     			header("Content-Type: {$fileType}");
    			// Output the image
     			echo $content;
   			}
			else
			{
				echo "<html><body>Error</body></html>";
			}
		}


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux