Jump to content

displaying base64 images - need help


dontQQ

Recommended Posts

I found this script a while ago to put images from a folder into a database.  I modified it and made some test output.

 

I have the output page displaying all the thumbnails images in one table, then creating links to the main images in another table.  I want the main images to be displayed in an iframe, but when I click on the thumbnails, a bunch of encoded base64 stuff appears.  :'(

 

Here's my what my output page is doing:

$sql = "SELECT * FROM thumbs;";
$result = mysql_query($sql);

while ($row = mysql_fetch_array($result) )
{
  $tid = $row["tid"];
  $encodeddata = $row["sixfourdata"];
  print "
    <a href=image.php?pid=$tid target=frame><img src=image.php?tid=$tid></a><BR><BR>
  ";
}

 

Here's what the image.php file is doing:

if ($_GET["pid"])
{
  $pid = $_GET["pid"];
  $sql = "SELECT * FROM pictures WHERE pid=$pid;";
  $result = mysql_query($sql);

  while ($row = mysql_fetch_array($result) )
  {
    $pid = $row["pid"];
    $encodeddata = $row["sixfourdata"];
  }

  mysql_close($conn);
  echo base64_decode($encodeddata);
}

if ($_GET["tid"])
{
  $tid = $_GET["tid"];
  $sql = "SELECT * FROM thumbs WHERE tid=$tid;";
  $result = mysql_query($sql);

  while ($row = mysql_fetch_array($result) )
  {
    $tid = $row["tid"];
    $encodeddata = $row["sixfourdata"];
  }

  mysql_close($conn);
  echo base64_decode($encodeddata);
}

 

pid stands for picture id.  tid stands for thumb id.

 

If anyone could help me with getting the picture to be correctly displayed in the frame, that'd be great.  If I'm being a newb, you can laugh, but still please help. ><

Link to comment
https://forums.phpfreaks.com/topic/47064-displaying-base64-images-need-help/
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.