I have an image that is stored in a folder directory, and I was wondering how I can use php to retrieve that image by its name and directory with a search.

I do have a search that will retrieve information on mysql, but I don't know the code to retrieve information from a local folder?


Member Avatar for diafol

Have a look at the functions in SPL. If you're looking for something simpler and you have the filename already - check for its existence with file_exists(). Check out the file functions in the php manual:


Be careful though, when using paths to files. Most don't reference in the same was as 'href' or 'src' attributes in html. They usually access the webroot if you use an absolute reference ("/...").

I do want to search and have the filename in the weblink. and what is SPL? sorry, i'm new to this

You must stored the path of the image file into mysql database. Then try to query the file path using PHP.

Okay, thanks guys. i'll give these a try!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.