By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,890 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,890 IT Pros & Developers. It's quick & easy.

is_file() fails on actual files, why?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.