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 02-27-2010, 01:09 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 Check if specific folder contains files, folders, both or none ?

Good day to you all,
is there a way to check if a specific folder contains: files, folder, both or none ?

I read my folder with Glob, like my code here :

PHP Code:

<?PHP
function globDir($dir)
{
   
$files glob("$dir/*"GLOB_ONLYDIR);
   
     if(!empty(
$files))
   {
      echo 
"<ul>\n";

      foreach(
$files as $file)
      {
         echo 
"<li><b>"basename($file)."</b>\n";
         
globDir($file);
         echo 
"</li>\n";
      }
      echo 
"</ul>\n";
   }
}
globDir('Photos');
?>

The only thing I have really found is how to find if a specific file exists.

I'm trying to find out if a specific folder contains : files, folders, both, none.
It would return the appropriate word accordingly.

Thanks and take care!
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 02-27-2010, 04:36 AM   #2 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Have a look at this script, it can list the contents of a folder and discern between files and folders. You should be able to modify that to fit your needs.
__________________

Village Idiot 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
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Listing files and folders with scandir Jmz General 1 08-29-2009 10:05 AM
How use PHP to read image files from a folder and display them in Flex 3 tilelist. chunL Absolute Beginners 12 07-13-2009 01:49 AM
Files appear as folders? Randy Absolute Beginners 5 07-08-2009 06:55 PM
Listing folders in list box, folder only, recursively Peuplarchie General 1 06-28-2009 08:59 PM


All times are GMT. The time now is 02:29 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