I've stored an image file on my local drive and the path to that image in my database. How can I retrieve the image for displaying it in PHP?
+1
A:
Select the data from the DB into variables ($path and $image_name).
echo it (in your view file):
echo "<img src='{$path}/{$image_name}' />";
Itay Moav
2010-07-08 17:06:29
A:
If you're trying to write a script to serve the image up on demand, you'll want to take a look at the readfile()
funtion: http://php.net/manual/en/function.readfile.php
You should store the content-type that was sent when the file was originally uploaded too. Keep this with the other information you've saved about the image in the database.
derkyjadex
2010-07-08 17:08:17
No need to send file to Output buffer...
Codex73
2010-07-28 01:50:21
As I said, if you're trying to serve the file ("displaying it in PHP"), use readfile() to send it to the output buffer. We don't know that the local path is publicly accessible.
derkyjadex
2010-07-29 16:35:52