Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP: BLOB and DB2

Status
Not open for further replies.

AIX5L

Technical User
Joined
Jul 27, 2001
Messages
228
Location
CH
Hi ALL

I wont to select an Image in my DB2 Database and display it.
Are there better solutions then this: ?

$Link_ID = odbc_connect("DSN", "user", "pass");
$Query_ID = odbc_exec($Link_ID, "SELECT picture FROM Previews");

// change to ODBC_BINMODE_CONVERT for comparison

odbc_binmode($Query_ID, ODBC_BINMODE_RETURN);

$Images = odbc_result($Query_ID, 1);

echo $Images;
 
I can't comment on yor DB2 code -- I've never used DB2 with PHP. However, at the very least you must set the Content-Type to the appropriate type for your image.

In general, though, I recommend against storing images in a database, but rather storing the image on the filesystem and the filename in the database.

If you store just the filename, you simply output an IMG tag, and the web server can handle sending the image to the browser. If you store the image in the database, you will have to provide all the additional code to fetch and stream the image.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Hi sleipnir214

Ok, but if the Image Location in FS will change, i lose my Reference. I will upload Images with a Limitation restriction in php.ini -> maxfile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top