retrieve image from directory

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
User avatar
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Thu Feb 17, 2011 6:59 am

What is it that you are trying to do?
I don't recommend storing images inside a db.. only the image name.

User avatar
php-forum Fan User
php-forum Fan User
Posts: 979
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI

Tue Feb 22, 2011 9:39 am

What they are trying to say is:

The recommended method for this is to store all of your images in a folder on your server for this example we will use a folder called "images" just inside your public_html folder

Now store just the file name (preferably with the extension unless you are only using one image type) into a field in your database

Lastly, you want to query for the image's file name and insert it into either a relative url:
<img src='/images/$filename'>

or into a fully qualified url:
<img src='http://www.<host>.com/images/$filename'>

Now if you are trying to use an image to query a database you can still do that, but you would need to get the image's file name and query based on that.

If you meant that you want to use an Image File as a query variable... you shouldn't do that.

Post Reply