Php > Databases
How to show images stored in a database
How to show images stored in a database There have been a number of questions lately about storing images in a db table and then how to show them correctly. The problem is that the header for images needs to be set correctly for the binary data to be show correctly. Here are the two working pages (tested my machine (xp, apache2, php4.3.9 mysql 4.01.x) In the areas for the db query you will see the notation $result = connect(sql); connect is a custom function to handle all db interatction that is separate from the pages and included in the conn.php file. There is another example with that function in my previously posted code samples.
"; echo "
\n"; }; ?> Database table: CREATE TABLE binary_data ( id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, description CHAR(50), bin_data LONGBLOB, filename CHAR(50), filesize CHAR(50), filetype CHAR(50) );
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage