skeetley Posted November 15, 2006 Share Posted November 15, 2006 I am looking for a very simple script to auto retrieve the images from a dir and show them. I don't care if the file needs to be placed in that dir or any other dir. I don't care about formatting the output. I just want a resulting page that I can go to and quickly scroll through my images.I have checked the google and all I can find are scripts for actual image galleries. I don't want to put that much work into this. The ones that I thought should work, I couldn't get to work.I used the search here. The only similar question I found went unanswered.Perhaps I am searching for the wrong terms. Anyone know what I should search for? Or know of such a script?Many thanks. Link to comment https://forums.phpfreaks.com/topic/27294-script-to-display-all-images-in-directory/ Share on other sites More sharing options...
doni49 Posted November 15, 2006 Share Posted November 15, 2006 Have a look here. www.php.net/diruse the dir function to return a list of files in the folder.then once you have your list you can lloop through the list and write your image tags:foreach($files as $file){ echo '<img src="' . $file . '">';} Link to comment https://forums.phpfreaks.com/topic/27294-script-to-display-all-images-in-directory/#findComment-124808 Share on other sites More sharing options...
jsladek Posted November 15, 2006 Share Posted November 15, 2006 Just wrote this real quick[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><body><center> <?foreach (glob("images/*.*") as $filename){ print("<a href=\"$filename\">$filename<br><img src=\"$filename\"></a><hr>");}?></center></body></html>[/code]Regards,John Sladekcan someone tell me how to put code in the post highliged as PHP. I'm using the [ c o d e] tags Link to comment https://forums.phpfreaks.com/topic/27294-script-to-display-all-images-in-directory/#findComment-124812 Share on other sites More sharing options...
skeetley Posted November 15, 2006 Author Share Posted November 15, 2006 Thank you both! Your script works and is exactly what I need John. Link to comment https://forums.phpfreaks.com/topic/27294-script-to-display-all-images-in-directory/#findComment-124814 Share on other sites More sharing options...
SharkBait Posted November 15, 2006 Share Posted November 15, 2006 [quote author=jsladek link=topic=115024.msg468199#msg468199 date=1163557993]Just wrote this real quick[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Untitled Document</title></head><body><center> <?foreach (glob("images/*.*") as $filename){ print("<a href=\"$filename\">$filename<br><img src=\"$filename\"></a><hr>");}?></center></body></html>[/code]Regards,John Sladekcan someone tell me how to put code in the post highliged as PHP. I'm using the [ c o d e] tags[/quote]Just use <?php and ?> inside your [ co de] tags :) Link to comment https://forums.phpfreaks.com/topic/27294-script-to-display-all-images-in-directory/#findComment-124882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.