TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-22-2009, 12:39 AM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application Seperate directory reading

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 :

PHP 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!
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 04-22-2009, 09:05 AM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

With all of these threads about reading files from a directory, please start separating your code into specific tasks. For this particular thread:
  1. Gather list of images in the directory
  2. Iterate over that list ordering by orientation (landscape/portrait)
  3. Display that sorted list in your required format (JavaScript in this case)

To help you determine which images are landscape or portrait you could use the getimagesize function.
Salathe is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Directory Support? delayedinsanity General 4 11-08-2012 09:04 PM
Directory site maintenance oMIKEo Absolute Beginners 6 04-22-2009 09:20 PM
[How To] Allow / Disallow Directory Browsing dynaweb Tips & Tricks 6 04-14-2009 12:57 PM
How do I find the most recently uploaded file in a directory? buildakicker General 2 02-19-2009 07:55 PM
Creating directory hierarchies with ease Wildhoney Script Giveaway 3 12-04-2008 02:28 AM


All times are GMT. The time now is 06:58 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design