rhostager
|
| Posted: 09/09/2002, 9:06 AM |
|
How do I display a jpeg stored as a BLOB in my MySql database as an image using CCS and PHP4 with templates? I did this with CC but can't seem to do it with CCS.
- Rob
|
|
|
 |
rhostager
|
| Posted: 09/10/2002, 8:22 PM |
|
I figured this out on my own. I took the original code provided by CodeCharge and modified it for CCS. Here is how I got it to work:
The problem with displaying a BLOB as a photo is that you have to "trick" the system into thinking it is loading the image from a normal link. Here is what I did to accomplish this. I created a blank page called "show_image". The HTML on this page was edited so the following items looked like this:
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="image/jpeg">
Notice that the content type is image/jpeg.
I created a simple Record called "Picture" on the show_image page.
Before Show of Record "Picture" on page show_image
//Custom Code @8-2A29BDB7
// -------------------------
// My database connection name is GCC_XP
global $DBGCC_XP;
global $Picture;
// The id of the person is passed so we can display the picture
$image_id = CCGetParam("person_id","");
$thePhoto = CCDLookUp("photo", "member_photos", "person_id=" . $DBGCC_XP->ToSQL($image_id, ccsInteger), $DBGCC_XP);
if ($thePhoto == "") {
//If no photo stored, display a default photo located at person id of zero
$thePhoto = CCDLookUp("photo", "member_photos", "person_id=0", $DBGCC_XP);
}
echo $thePhoto;
exit();
// ----------------------
Here is how I call the photo to be displayed:
On the Before Show of a label called "photo" on a record called "Photo" on a page called MyInfo I add this code:
//Custom Code @63-2A29BDB7
// -------------------------
global $Photo;
$image_id = CCGetSession("PersonID");
$Photo->photo->SetValue("<img src=\"show_image.php?person_id=" . $image_id . "&quirk=" . time() . "\" width=150 height=200></a>");
// -------------------------
//End Custom Code
Works great!
Hope this helps someone.
- Rob
|
|
|
 |
|