php, postgresql and graphical images

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



Hi all!

Does anybody have any experience in displaying images stored in postgresql database? I'm trying to export image into file using pg_lo_export function and then view it on html page. However, the pg_lo_export seem to work only occasionaly.

The code is like this:
(php5, postgresql 8.2)
*****************
$no++; //Incerementing number of the image
pg_query("Begin");
$query = "select pic_data, accurateness_level, mime_type from image2 where
          *****//condition clause";
$row = pg_fetch_row(pg_query($query));
// Get the image OID
$image = $row[0];
// Get the type of the picture
$type = $row[2];
// Export the picture into pic.type
pg_lo_export($image, "pic$no.$type");
//get image file dimensions
$dimensions = getimagesize("pic$no.$type");
$width = $dimensions[0];
$height = $dimensions[1];
// Show the picture
echo "<img src=\"pic$no.$type\" width=" . $width . " height=" . $height . "/>";
pg_query("Commit");
*************

I understand that the script doesn't like the idea of saving files on the server. However, why does it work at all?
Are there any other ways to export images from the database?

Any comments are welcome.

- Mike


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux