473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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>

Apr 10 '07 #1
5 5403
Tyno Gendo wrote:
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.
Apr 10 '07 #2
Tyno Gendo wrote:
Tyno Gendo wrote:
>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:-/
Apr 10 '07 #3
.. 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"?

--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Apr 11 '07 #4
Willem Bogaerts wrote:
>.. 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"); ?
Apr 11 '07 #5
Willem Bogaerts wrote:
>.. 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;
}
}
?>

Apr 11 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil Powell | last post by:
Code snippet: if (!($dirID = opendir($ACTUAL_STARTPATH . '/content/')) && $hasCookie) { $html .= $font . '<font color=cc0000><li>Could not open files in content folder</li></font></font><p>'; }...
2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
1
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. I'm having trouble getting the code that I've written to work, can anyone shed some light as to where I'm...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
6
by: Kimmo Laine | last post by:
Running IIS 6 on Windows 2003 server. After an update to the most recent version of php 5.1.2, for some reacon a function handling uploaded files using is_file stopped working. is_file failed...
2
by: sambo251 | last post by:
After running a few updates I get this very annoying "Windows Installer" error #1706 that will ne go away! It keeps saying that it cannot find the file "instantsharedevices.msi", that it is on...
1
by: mfunkmann | last post by:
Hi, I recently got an error and I don't know how to fix it: Error 1 'System.Data.DataColumn' does not contain a definition for 'Windows' C:\c#\CsharpPRO\Form1.Designer.cs 304 77 CsharpPRO I...
2
by: Confused but working on it | last post by:
Thanks for the help with escaping that line. My gallery works great. Just lines up the pictures and if you resize they move with it instead of using tables. Added a class to pad each image and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.