Forum Moderators: coopster
I have recently made a vey simple php forum and have allowed users to upload a small 50x50 pixel avatar under 5kb each. I figured it would be better to store them in mysql than mess around with file handling and overwrites ect.
Is it a good idea to use blob in this instance?
I have had no trouble inseting the images into the database following a tutorial but i cant figure out how to display the blob with php and html.
So far i just echo the image and get the following
Ø£Lyu„+šƒ‡5'S\KˆeG8Ò›J’’‘SKf etc etc;
How do i turn it into a picture?
Thnaks for any help :)
[edited by: jatar_k at 2:39 pm (utc) on Oct. 29, 2005]
[edit reason] shortened garbage [/edit]
Thats a good idea.
I ended up getting my way to work and seems fast enough but i'll look into your suggestion.
How would you delete a users avatar if you removed them from your database? My way is just a matter of deleting the users record. Also, since their only avatars and each page will only ever have a max of 10 avatars showing, i think it should be fast enough.
Example code:
<?
/*
MYSQL Code Here
Your image contents have been stored in variable $imgcode
Your image type is stored in $imgtype
*/
header("Content-type: image/".$imgtype);
echo $imgcode;
?>
You would then put the name of this script in a normal img tag.
<img src="img.php?id=1234" alt="Avatar">