Scan dir, seperate file by name convension...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Peuplarchie
Forum Contributor
Posts: 148
Joined: Sat Feb 04, 2006 10:49 pm

Scan dir, seperate file by name convension...

Post by Peuplarchie »

Good day to you all,
here I have a script that show all images in a directory.

My questions :
1. How can I make my scan dir for each folder listed in the specified folder, only 1 level.
2. My naming convension is adding a "_1" at the end of the portrait images, "_0" to the landscape and "_2" to the end of a panoramic image.

How can I seperate the result ?

So basicly :

ACDC
Portrait images
Landscape images
Panoramic images

Aerosmith
Portrait images
Landscape images
Panoramic images

Here is my code right now :

Code: Select all

 
 
 
 
<?php
 
        set_time_limit(0);
        
        
        $dir = $_GET['dir'];
$directory = $dir;
 
$diri = $directory; //You could add a $_GET to change the directory
$files = scandir($diri);
echo "<div id=\"bar\"><b>".$directory."</b></div><br/>";
echo "<div>";
foreach($files as $key => $value){
    
    if ($value != "." && $value != "..") {
 
    echo "<a onmouseover=this.style.cursor=\"pointer\" ' onfocus='this.blur();' onclick=\"document.getElementById('".$value."').style.display = 'block' \" ><img src=\"".$directory."/".$value."\" width=\"50px\" class=\"imag\"></a>\n"; 
    echo "<div id='".$value."' style='display: none;  position: absolute;  text-align:left; margin: 0px -300px; margin-top:-150px;  z-index:50; border: solid black 1px; padding: 10px; background-color: #ffffff; text-align: justify; font-size: 12px; onmouseover='this.style.cursor=\"pointer\" ' style='font-size: 12px;' onfocus='this.blur();' onclick=\"document.getElementById('".$value."').style.display = 'none' \" >";
    echo "<img src=\"".$directory."/".$value."\" /><br />".$value."<br/></div>";
    
    
    }else{
        
        echo "";
        
        }
    
}
echo "</div>"
 
 ?>
 
 
 
Thanks !
Post Reply