i uploaded my images in mysql using blob with php coding. now how can i retrieve them and display inside a browser. ofcourse i also want swf files
+2
A:
header('Content-Type: image/jpeg'); # or another type
echo $result['image'];
The header function is the key. You need to tell the browser that this output is a certain type. For your swf, you need to use application/x-shockwave-flash
(at least that's what the first google hit produced).
Tor Valamo
2010-01-11 19:46:51
+2
A:
I beleive you need to make a script which you use in place of the image for example instead of:
<img src="/image/path/to/my/image.jpg />
you would have something like:
<img src="/image.php?image=image.jpg" />
So then in image.php you would need to do the following:
- Query the database for the record with the image, based on the parameters passed to image.php
- Do any necessary operations on the blob so you can ouput it
- set the proper http headers for the image
- print the blob data
For the most part its better to just store and maintain the path to an image on the filesystem/http instead of putting the actual image data in the db. There ae ofcourse all kinds of exceptions to that, but for the most part this is how its done.
prodigitalson
2010-01-11 19:46:53
You can also get a performance boost by checking the image/file table for a modified time and then using that to check if it has been modified when the browser does a 304 request. See 304 here for more info: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Kevin Peno
2010-01-11 20:11:20