Connecting Tech Pros Worldwide Help | Site Map

is_file under windows

 
LinkBack Thread Tools Search this Thread
  #1  
Old April 10th, 2007, 04:25 PM
Tyno Gendo
Guest
 
Posts: n/a
Default is_file under windows


How do you normally check filetypes? I ended up resorting to
!is_dir($file) as all other calls seem to fail so I had to assume if not
a directory its a file, rather than specifically checking if its a file.

I'm recursing a folder:

<?php
$cat_seq = 1;
$path = "e:\\videos\\$cat_seq";
$dh = opendir($path);
while ($file = readdir($dh)) {
echo filetype($file)."<br />";
if ( !is_dir($file) ) {
echo $file;
}
}
?>

Under windows, I can try is_file(), this always returns "" (nothing),
and if I try filetype($file) (as above on the echo) I can get 'dir' for
directories but get the following for files:

Warning: filetype() [function.filetype]: Lstat failed for <filename>


  #2  
Old April 10th, 2007, 04:55 PM
Tyno Gendo
Guest
 
Posts: n/a
Default Re: is_file under windows

Tyno Gendo wrote:
Quote:
Under windows, I can try is_file(), this always returns "" (nothing),
and if I try filetype($file) (as above on the echo) I can get 'dir' for
directories but get the following for files:
>
Warning: filetype() [function.filetype]: Lstat failed for <filename>
>
I'm running PHP 5.2 on WinXP with Apache 2 if that helps.
  #3  
Old April 10th, 2007, 04:55 PM
Tyno Gendo
Guest
 
Posts: n/a
Default Re: is_file under windows

Tyno Gendo wrote:
Quote:
Tyno Gendo wrote:
Quote:
>Under windows, I can try is_file(), this always returns "" (nothing),
>and if I try filetype($file) (as above on the echo) I can get 'dir'
>for directories but get the following for files:
>>
>Warning: filetype() [function.filetype]: Lstat failed for <filename>
>>
>
I'm running PHP 5.2 on WinXP with Apache 2 if that helps.
... I just uploaded to a linux server to test, same result. Files exist
because i'm just recursing a directory now and printing out the names of
things that it finds along with an is_file($file) as well, always
returns <blank:-/
  #4  
Old April 11th, 2007, 07:05 AM
Willem Bogaerts
Guest
 
Posts: n/a
Default Re: is_file under windows

.. I just uploaded to a linux server to test, same result. Files exist
Quote:
because i'm just recursing a directory now and printing out the names of
things that it finds along with an is_file($file) as well, always
returns <blank:-/

What do you pass to the is_file() function? The full path or just the
"basename"?

--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
  #5  
Old April 11th, 2007, 08:15 AM
Tyno Gendo
Guest
 
Posts: n/a
Default Re: is_file under windows

Willem Bogaerts wrote:
Quote:
Quote:
>.. I just uploaded to a linux server to test, same result. Files exist
>because i'm just recursing a directory now and printing out the names of
>things that it finds along with an is_file($file) as well, always
>returns <blank:-/
>
>
What do you pass to the is_file() function? The full path or just the
"basename"?
>
In this instance I have passed fullname. I could try a chdir and then
is_file("./$file"); ?
  #6  
Old April 11th, 2007, 08:25 AM
Tyno Gendo
Guest
 
Posts: n/a
Default Re: is_file under windows (SOLVED)

Willem Bogaerts wrote:
Quote:
Quote:
>.. I just uploaded to a linux server to test, same result. Files exist
>because i'm just recursing a directory now and printing out the names of
>things that it finds along with an is_file($file) as well, always
>returns <blank:-/
>
>
What do you pass to the is_file() function? The full path or just the
"basename"?
>
Thanks Willem,

I changed the test code as follows and used chdir to move into the base
directory first, then I just opened "." as the directory and checked the
file, it works. Code as follows checking for video files in a category
folder:

<?php
$cat_seq = 1;
$path = "e:\\videos\\$cat_seq";
chdir($path);
$dh = opendir(".") or die('cannot open directory');
while ($file = readdir($dh)) {
if ( is_file($file) ) {
echo $file;
}
}
?>

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.