Current location: Hot Scripts Forums » Programming Languages » PHP » Dir showing as file

Dir showing as file

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-10-04, 12:32 PM
jack_mcs jack_mcs is offline
Newbie Coder
 
Join Date: Aug 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Dir showing as file

I have a test directory that contains one directory and one file. I want my program to search through this test directory and find the file. But the code is not recognizing the sub-directory as a directory and treats it as a file. The section of code where I am testing for this looks like this. I am testing in three different ways trying to find the problem.
Code:
 $dir_handle = @opendir($srce) or die("Unable to open $srce"); 
 while (false !== ($file = readdir($dir_handle))) { 
  var_dump(is_dir('$file')) . "\n"; 
  if (is_dir($file))
   echo 'Dir1 = '.$file.'<br>';
  if (filetype($file) == "dir") 
   echo 'Dir2 = '.$file.'<br>';
When the test directory is read, I get four entries:
. //should be a dir
.. //should be a dir
edited //should be a dir
file.php //should be a file

The output of var_dump is false for all four while is_dir and filetype recognize the first two as directories but the see the last two as files. Can anyone see where I might be going wrong?

Jack
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Server open file altafingar ASP.NET 1 10-20-04 01:12 AM
file upload csmaster2005 PHP 1 06-16-04 07:57 PM
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 04:09 PM
Please I Need help before all my hair is gone! LisatheNovice Perl 6 11-22-03 04:05 PM
Upload file type and size limiter! Arctic ASP 1 08-02-03 08:06 PM


All times are GMT -5. The time now is 03:19 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.