Yojance Posted May 9, 2006 Share Posted May 9, 2006 I've been wanting to do this for some time now, but I still dont know how to do it.Basicly it's a script that will display every image on a web directory. When I say display, I mean show the real image not the link like usual. I don't know how to tell php to go thru every image on a directory, so I'm asking you to help me do this. The rest I can probably figure it out in a day or two.I hope you can help me.Thank you. Quote Link to comment Share on other sites More sharing options...
Prismatic Posted May 9, 2006 Share Posted May 9, 2006 [!--quoteo(post=372651:date=May 9 2006, 11:45 AM:name=Yojance)--][div class=\'quotetop\']QUOTE(Yojance @ May 9 2006, 11:45 AM) [snapback]372651[/snapback][/div][div class=\'quotemain\'][!--quotec--]I've been wanting to do this for some time now, but I still dont know how to do it.Basicly it's a script that will display every image on a web directory. When I say display, I mean show the real image not the link like usual. I don't know how to tell php to go thru every image on a directory, so I'm asking you to help me do this. The rest I can probably figure it out in a day or two.I hope you can help me.Thank you.[/quote]Place this in the folder of the images[code]<?php//Images to ignore, File name ONLY, no extension, seperate by a comma, no spaces//Example: $ignoreimages = "BlahImage,ImageMeh";$ignoreimages = "";$direc = getcwd();$dh = opendir($direc);while (false !== ($filename = readdir($dh))) { $files[] = $filename;}//Build the file as an HTML$output .= "<html> <head> <title>Image Dump</title> <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> </head> <body bgcolor='B1B3BC'>";//Show Current Dir$output .= "Image Dump of directory: $direc<br>";//Accepted File Types To display$acceptedfiles = array(1 => "jpg", 2 => "JPG", 3 => "jpeg", 4 => "JPEG");//Build the array that holds the files to exclude.$ignore = explode(",", $ignoreimages);$FileCount = count($files);for($i=0; $i <= $FileCount; $i++){ $file1 = explode(".", $files[$i]); $blah = count($file1); $extension = $file1[$blah]; $filename = $file1[$blah -1]; if(in_array("$extension", $acceptedfiles)) { if(in_array("$filename", $ignore)){ //Do Nothing } else{ $output .= "<a href='$files[$i]'><img src='$files[$i]' alt=''></a>"; } } else{ //Do Nothing }}//Close the file out$output .= "</body> </html>";//output the HTMLecho $output;?>[/code] Quote Link to comment Share on other sites More sharing options...
Yojance Posted May 9, 2006 Author Share Posted May 9, 2006 Wow, i never thought it would be so complicated.Thank you Prismatic Quote Link to comment Share on other sites More sharing options...
Prismatic Posted May 9, 2006 Share Posted May 9, 2006 [!--quoteo(post=372746:date=May 9 2006, 03:39 PM:name=Yojance)--][div class=\'quotetop\']QUOTE(Yojance @ May 9 2006, 03:39 PM) [snapback]372746[/snapback][/div][div class=\'quotemain\'][!--quotec--]Wow, i never thought it would be so complicated.Thank you Prismatic[/quote]It's not that it's complicated, it can be really simple, I just gave you the ability to exclude images and filetypes from showing up :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.