Hi!
I am trying to display an image in my html document. The document contains
the following line:
<td class="Input">< img
src=getimage.ph p?tbl=dbo.Emplo yees&type=jpg&c ol=Photo&idCol= EmployeeID&id=1
Border=0 alt=''> </td>
This call getimage.php source. Following is the php source itself:
<?PHP
include_once('o rdersappdata.ph p');
$objConn1 = &ADONewConnecti on("mssql");
$objConn1->debug = $DebugMode;
$objConn1->Connect("serve r1","sa","sa200 0","northwind") ;
include_once('u tils.php');
$myQuote = "";
$objRSImage = "";
$strSQL = "";
$image = "";
$myType = "";
$handle = "";
$filename = 'test.txt';
$handle = fopen($filename , 'a');
//fwrite($handle, "Debug open");
//$myQuote = getQuote($objCo nn1, getGet("tbl"), getGet("idCol") );
$myQuote = "";
$strSQL = "select " . getGet("col") . " from " . getGet("tbl") . " where ";
$strSQL .= getGet("idCol") . " = " . $myQuote . getGet("id") . $myQuote;
//fwrite($handle, $strSQL . "\n");
$objRSImage = $objConn1->Execute($strSQ L);
if ($objRSImage):
//fwrite($handle, "Recordset OK" . "\n");
$image = $objRSImage->fields[getGet("col")];
$objRSImage->Close();
switch (getGet("type") ):
case "jpg":
//fwrite($handle, "Type = jpeg\n");
header("Content-type: image/jpeg");
$myType = "jpg";
break;
case "gif":
//fwrite($handle, "Type = gif\n");
header("Content-type: image/gif");
$myType = "gif";
break;
case "png":
//fwrite($handle, "Type = png\n");
header("Content-type: image/png");
$myType = "png";
break;
default:
//fwrite($handle, "Type = default\n");
if(ord($image[0]) == 255 && ord($image[1]) == 216 &&
ord($image[2]) == 255 && ord($image[3]) == 224):
header("Content-type: image/jpeg");
$myType = "jpg";
endif;
if(strcmp(subst r($image,0,3)," GIF") == 0):
header("Content-type: image/gif");
$myType = "gif";
endif;
if(ord($image[0]) == 137 && ord($image[1]) == 80 &&
ord($image[2]) == 78 && ord($image[3]) == 71 &&
ord($image[4]) == 13 && ord($image[5]) == 10 &&
ord($image[6]) == 26 && ord($image[7]) == 10):
header("Content-type: image/png");
$myType = "png";
endif;
endswitch;
header("Content-Disposition: attachment; filename=\"" . getGet("col") .
".$myType" . "\"\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . strlen($image) . "\n");
//fwrite($handle, "filename=\ "" . getGet("col") . ".$myType" . "\"\n");
print($image);
unset($image);
endif;
unset($objRSIma ge);
$objConn1->Close();
unset($objConn1 );
fclose($handle) ;
?>
The image is not displayed in the html document. Is someone can tell me why
it is not?
Many thanks!
Pierre Tremblay
I am trying to display an image in my html document. The document contains
the following line:
<td class="Input">< img
src=getimage.ph p?tbl=dbo.Emplo yees&type=jpg&c ol=Photo&idCol= EmployeeID&id=1
Border=0 alt=''> </td>
This call getimage.php source. Following is the php source itself:
<?PHP
include_once('o rdersappdata.ph p');
$objConn1 = &ADONewConnecti on("mssql");
$objConn1->debug = $DebugMode;
$objConn1->Connect("serve r1","sa","sa200 0","northwind") ;
include_once('u tils.php');
$myQuote = "";
$objRSImage = "";
$strSQL = "";
$image = "";
$myType = "";
$handle = "";
$filename = 'test.txt';
$handle = fopen($filename , 'a');
//fwrite($handle, "Debug open");
//$myQuote = getQuote($objCo nn1, getGet("tbl"), getGet("idCol") );
$myQuote = "";
$strSQL = "select " . getGet("col") . " from " . getGet("tbl") . " where ";
$strSQL .= getGet("idCol") . " = " . $myQuote . getGet("id") . $myQuote;
//fwrite($handle, $strSQL . "\n");
$objRSImage = $objConn1->Execute($strSQ L);
if ($objRSImage):
//fwrite($handle, "Recordset OK" . "\n");
$image = $objRSImage->fields[getGet("col")];
$objRSImage->Close();
switch (getGet("type") ):
case "jpg":
//fwrite($handle, "Type = jpeg\n");
header("Content-type: image/jpeg");
$myType = "jpg";
break;
case "gif":
//fwrite($handle, "Type = gif\n");
header("Content-type: image/gif");
$myType = "gif";
break;
case "png":
//fwrite($handle, "Type = png\n");
header("Content-type: image/png");
$myType = "png";
break;
default:
//fwrite($handle, "Type = default\n");
if(ord($image[0]) == 255 && ord($image[1]) == 216 &&
ord($image[2]) == 255 && ord($image[3]) == 224):
header("Content-type: image/jpeg");
$myType = "jpg";
endif;
if(strcmp(subst r($image,0,3)," GIF") == 0):
header("Content-type: image/gif");
$myType = "gif";
endif;
if(ord($image[0]) == 137 && ord($image[1]) == 80 &&
ord($image[2]) == 78 && ord($image[3]) == 71 &&
ord($image[4]) == 13 && ord($image[5]) == 10 &&
ord($image[6]) == 26 && ord($image[7]) == 10):
header("Content-type: image/png");
$myType = "png";
endif;
endswitch;
header("Content-Disposition: attachment; filename=\"" . getGet("col") .
".$myType" . "\"\n");
header("Content-Transfer-Encoding: binary\n");
header("Content-length: " . strlen($image) . "\n");
//fwrite($handle, "filename=\ "" . getGet("col") . ".$myType" . "\"\n");
print($image);
unset($image);
endif;
unset($objRSIma ge);
$objConn1->Close();
unset($objConn1 );
fclose($handle) ;
?>
The image is not displayed in the html document. Is someone can tell me why
it is not?
Many thanks!
Pierre Tremblay
Comment