Jump to content


Photo

Something I want to do


  • Please log in to reply
3 replies to this topic

#1 Yojance

Yojance
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 09 May 2006 - 04:45 PM

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.

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 09 May 2006 - 06:27 PM

[!--quoteo(post=372651:date=May 9 2006, 11:45 AM:name=Yojance)--][div class=\'quotetop\']QUOTE(Yojance @ May 9 2006, 11:45 AM) View Post[/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

<?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 HTML
echo $output;
?>


#3 Yojance

Yojance
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 09 May 2006 - 08:39 PM

Wow, i never thought it would be so complicated.
Thank you Prismatic

#4 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 09 May 2006 - 08:49 PM

[!--quoteo(post=372746:date=May 9 2006, 03:39 PM:name=Yojance)--][div class=\'quotetop\']QUOTE(Yojance @ May 9 2006, 03:39 PM) View Post[/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 :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users