tags:

views:

40

answers:

2

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
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
No need to send file to Output buffer...
Codex73
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