Jump to content

Something I want to do


Yojance

Recommended Posts

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.
Link to comment
Share on other sites

[!--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 HTML
echo $output;
?>
[/code]
Link to comment
Share on other sites

[!--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 :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.