ユーザーがアップロードした画像をユーザー プロフィール ページに表示しようとしています。画像は正常にアップロードされていますが、表示時に「エラーが含まれているため、画像を表示できません」というエラーが表示されます。
私のアップロードコードは次のとおりです。
<?php
session_start();
require_once("config.php");
header ("Content-type: image/jpg" );
if ( $_GET["id"] != "" )
{
if ( file_exists ( "media/userphotos/".$_GET["id"].".jpg" ) )
$imageToShow = SITEURL."media/userphotos/".$_GET["id"].".jpg";
else
{
$imgNumber = rand ( 1, 5 );
$imageToShow = SITEURL."images/nimg$imgNumber.jpg";
}
}
if ( strchr ( $imageToShow , ".gif" ) )
$image = imagecreatefromgif ( $imageToShow );
else
$image = imagecreatefromjpeg ( $imageToShow );
list ( $width, $height ) = getimagesize ( $imageToShow );
$diffWidth = 1;
$diffHeight = 1;
if ( $width > $height )
{
if ( $width > 130 )
{
$diffWidth = 1 - ( ( $width-130 ) / $width ) ;
$diffHeight = $diffWidth ;
}
}
else
{
if ( $height > 110 )
{
$diffHeight = 1 - ( ( $height-110 ) / $height ) ;
$diffWidth = $diffHeight ;
}
}
$modwidth = $width * $diffWidth ;
$modheight = $height * $diffHeight ;
//$modwidth = 130 ;
//$modheight = 110 ;
// Resizing the Image
$tn = imagecreatetruecolor ( $modwidth, $modheight ) ;
imagecopyresampled ( $tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height ) ;
/******** this line outputs image as thumbnail or not ( conditioned ) *********/
if ( $tn )
imagejpeg( $tn , "" , 99 ) ;
else
imagejpeg( $image , "" , 99 ) ;
imagedestroy ( $image ) ;
?>
私が使用する画像を表示するには:
<img src="<?php echo SITEURL."userimage.php?id=".$userDetails["UserID"] ?>" style="width:120px; padding:2px; border:#999999 1px solid;" />
画像が表示されない理由を誰か説明できますか?