473,397 Members | 2,028 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,397 software developers and data experts.

is_file() fails on actual files, why?

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>';
} else if ($hasCookie) {

clearstatcache(); // CLEAR THE STATUS CACHE FOR is_file() TO PROPERLY
DETERMINE FILE STATUS
$html .= $font . 'Contents: <p>';
while (($file = readdir($dirID)) !== false) {
if (is_file($file) || !preg_match('/^\./', $file)) {
$html .= "\n<br><a href=/content/" . substr($file, strrpos('/', $file),
strlen($file)) .
'>' . substr($file, strrpos('/', $file), strlen($file)) .
"</a><p>\n";
}
}
}

where $ACTUAL_STARTPATH is the actual path for each file. However, whenever
I try to check to see if a read file is an actual file and not either a
directory, '.' nor '..', it constantly skips every legitimate file! These
files have extensions of .html, .txt, .doc, .pdf, etc.

Is is_dir() then a failed PHP command?

Phil
Jul 16 '05 #1
2 6140
On Mon, 18 Aug 2003 02:43:07 -0400, "Phil Powell" <so*****@erols.com>
wrote:
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>';
} else if ($hasCookie) {

clearstatcache(); // CLEAR THE STATUS CACHE FOR is_file() TO PROPERLY
DETERMINE FILE STATUS
$html .= $font . 'Contents: <p>';
while (($file = readdir($dirID)) !== false) {
if (is_file($file) || !preg_match('/^\./', $file)) {


readdir returns filenames only, not paths. You're getting is_file to
look at the wrong directory, unless the current directory happens to
be the one you're scanning with opendir.

Jul 16 '05 #2
That wasn't the problem; the problem was that the files were of permission
0700 along with the folder. It was physically unable to open the directory,
much less the files. I gave up on a PHP solution and wrote it in TCL CGI
and it works.

Thanx though
Phil

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:9u********************************@4ax.com...
On Mon, 18 Aug 2003 02:43:07 -0400, "Phil Powell" <so*****@erols.com>
wrote:
Code snippet:

if (!($dirID = opendir($ACTUAL_STARTPATH . '/content/')) && $hasCookie) {
$html .= $font . '<font color=cc0000><li>Could not open files in contentfolder</li></font></font><p>';
} else if ($hasCookie) {

clearstatcache(); // CLEAR THE STATUS CACHE FOR is_file() TO PROPERLY
DETERMINE FILE STATUS
$html .= $font . 'Contents: <p>';
while (($file = readdir($dirID)) !== false) {
if (is_file($file) || !preg_match('/^\./', $file)) {


readdir returns filenames only, not paths. You're getting is_file to
look at the wrong directory, unless the current directory happens to
be the one you're scanning with opendir.

Jul 16 '05 #3

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

Similar topics

5
by: ravenslay3r | last post by:
I'm using a script to grab images from a directory and put them to the screen, but i want it to ignore sub-directories like CVS/ . Adding the tag "&& !is_dir($file)" to the correct conditional...
6
by: afh3 | last post by:
Create a setup.exe deployment package and try to execute it on a server with 2TB of disk space. The installer will report that the drive is negative in size, and will therefore refuse to install. ...
36
by: Thomas | last post by:
after spending countless hours trying, i give up and hope to get some help in here. on server1 i got the web myweb.com with my test.asp. in the test.asp, i'm trying to read a file from an UNC...
2
by: hubert_s | last post by:
I have DB2 8.1 FP7, when I try to build a Java stored procedure it fails during a call to DB2_REPLACE_JAR. Even the build folder "bld1096553970703" is not there - it has a different name, ...
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...
12
by: Jim Rodgers | last post by:
I have a big asp file that has an error under certain conditions -- totally repeatable. However, it only fails when I set response.buffer = True at the top. WHen I set it False in order to debug...
5
by: Tyno Gendo | last post by:
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...
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...
7
by: Richie Kernagan | last post by:
Howdy Problem with the fread() call on MS Visual Studio 2005 running under Win 64. The parameters to fread size and count are both size_t ie 64 bits. Even so the call fails when the size arg...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.