Hi i would like to fetch images from name of the image by which i have stored the image from the upload folder. how can i do it in wordpress.

Recommended Answers

All 5 Replies

Member Avatar for diafol

Show any code that you have so far.

//Path to folder which contains images
$dirname = "../public_html/wp-content/uploads/2015/tc/";

//Use glob function to get the files
//Note that we have used " * " inside this function. If you want to get only JPEG or PNG use
//below line and commnent $images variable currently in use
$images = glob($dirname."*");

//Display image using foreach loop
foreach($images as $image) {

//print the image to browser with anchor tag (Use if you want really :) )
echo '<p><a href="'.$image.'" target="_blank"><img src="'.$image.'" alt="filename" /></a></p>';
Member Avatar for diafol

So this doesn't wwork for you?

ya also i tried other codes but sometimes getting error in sql query or many methods i have tried like uploading image to folder setting up the file path in database then trying to fetch i got stuck with all.
It would be great help if you can provide for the same.

Member Avatar for diafol

I.m confused as to what part of the code doesn't work. SQL and writing to db is all down to you, nothing to do with other people's scripts. Your best bet is to stick with a trusted script and persevere IMO.

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.