|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-07-11 14:37 UTC] itamarc at rogers dot com
Description: ------------ some directories don't show as such. even when using chdir() and looking at all notes on the subject. I have had and reprocudes this problem for months. so please don't just say it's crap. Reproduce code: --------------- goto http://zabber.portredirect.com/ login as php password is net goto 'Members Options' goto 'User Files' goto 'Manage Folders' I used the site to make 3 folders. Click on "Make New Directory" See what it says in the file list. source code used is available to anyone who E-mails me at: zabber@rogers.com Expected result: ---------------- should who first folder and subfolder as such. but second folder and any uploaded files show wrong. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 17:00:02 2025 UTC |
function getDirList($pop, $log) { $path = ""; if (false !== ($directory = dir("$pop"))) { $dir = $directory->path; print "$dir"; chdir($dir); while (false !== ($entry = $directory->read())) { $path = "$entry"; if (!is_file($dir."/".$entry) && !is_link($path) && file_exists($path)) { if ($entry !== "." && $entry !== "..") { if ($dir == $log) { print "<option value='/$entry'>/$entry</option>\n"; getDirList($entry, $log); } else { print "<option value='/$dir/$entry'>/$dir/$entry</option>\n"; getDirList($entry, $log); } } $j++; } else { print "<option value='$dir/$entry'>file: $dir/$entry</option>\n"; } } $directory->close(); } }After testing your function on my system, and modifying it a bit I made it work (as I think it should work). With this new function I can list the content of any folder on my XP system. function getDirList($pop, $log) { if (false !== ($directory = dir("$pop"))) { $dir = $directory->path; while (false !== ($entry = $directory->read())) { if (!is_file($dir."/".$entry) && !is_link($entry) && file_exists($entry)) { if ($entry !== "." && $entry !== "..") { if ($dir == $log) { print "<option value='$entry'>$entry</option>\n"; getDirList($entry, $log); } else { print "<option value='$dir/$entry'>$dir/$entry</option>\n"; getDirList($entry, $log); } } } else { print "<option value='$dir/$entry'>file: $dir/$entry</option>\n"; } } $directory->close(); } }I guess I should test a bit more before I post :-) This is the code that works. function getDirList($pop, $log) { if (false !== ($directory = dir("$pop"))) { $dir = $directory->path; while (false !== ($entry = $directory->read())) { $path = "$dir/$entry"; if (!is_file($path) && !is_link($path) && file_exists($path)) { if ($entry !== "." && $entry !== "..") { if ($dir == $log) { print "<option value='$entry'>$entry</option>\n"; } else { print "<option value='$dir/$entry'>$dir/$entry</option>\n"; } getDirList($path, $log); } } else { print "<option value='$dir/$entry'>file: $dir/$entry</option>\n"; } } $directory->close(); } }