Jump to content

Seperate directory reading


Peuplarchie

Recommended Posts

Good day to you all,

                I was wondering how to seperate the result of a direcory read.

                Example, I know the files will be images.

 

How can I show the portrait first and then landscape second ?   

 

here is my code :

 



<html>
<head>

    <SCRIPT language="JavaScript">
    <!--
    if (document.images)
    {
      preload_image = new Image(25,25); 
<?PHP
//  directory name sent by url
$dir = $_GET['dir'];
$file = $_GET['file'];

//define the path as relative
$path = $dir."".$file;

//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");

echo "Directory Listing of $path<br/>";

//running the while loop
while ($file = readdir($dir_handle)) 
{
   if($file!="." && $file!="..")

      echo "preload_image.src=\"http://test.peuplies.info/PHP/Photos_gallery/".$path."/".$file.""; 

}

echo "} //-> </script> </head> <body><center>";



while ($file = readdir($dir_handle)) 
{
   if($file!="." && $file!="..")

      echo "<img src=\"".$path."/".$file."\" width=\"50px\">"; 

}







//closing the directory
closedir($dir_handle);


?>



</center>

</body>
</html>

 

 

Thanks! 

Link to comment
https://forums.phpfreaks.com/topic/155127-seperate-directory-reading/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.