jonoc33 Posted October 13, 2007 Share Posted October 13, 2007 I recently wrote an upload script, and along with it when you uploaded it a directory listing script shows the files in the uploaded folder. <?PHP $folder = "files/upload/"; $handle = opendir($folder); # Making an array containing the files in the current directory: while ($file = readdir($handle)) { $files[] = $file; } closedir($handle); #echo the files foreach ($files as $file) { echo "-<a href=$folder$file>$file</a>"."<br />"; } ?> That is the directory listing script. Although.. when it shows the files it comes up with these dots eg: Uploaded Files -.. -Picture.gif -. -Blah.doc Anyone know as to why these dots would show up? Quote Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/ Share on other sites More sharing options...
matto Posted October 13, 2007 Share Posted October 13, 2007 That is quite normal, just exclude them from your output. Quote Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/#findComment-368503 Share on other sites More sharing options...
jonoc33 Posted October 13, 2007 Author Share Posted October 13, 2007 Ok..Well.. how do I do that? Quote Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/#findComment-368509 Share on other sites More sharing options...
kenrbnsn Posted October 13, 2007 Share Posted October 13, 2007 The "." is the UNIX shorthand for "this directory" and the ".." is the UNIX shorthand for the previous directory. To eliminate them use: <?php while (false !== ($file = readdir($handle))) if ($file != '.' && $file != '..') $files[] = $file; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/#findComment-368527 Share on other sites More sharing options...
jonoc33 Posted October 13, 2007 Author Share Posted October 13, 2007 The "." is the UNIX shorthand for "this directory" and the ".." is the UNIX shorthand for the previous directory. To eliminate them use: <?php while (false !== ($file = readdir($handle))) if ($file != '.' && $file != '..') $files[] = $file; ?> Ken Thankyou. That worked. Quote Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/#findComment-368535 Share on other sites More sharing options...
kenrbnsn Posted October 13, 2007 Share Posted October 13, 2007 Replace: <?php while ($file = readdir($handle)) { $files[] = $file; } ?> with my code. Ken Quote Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/#findComment-368537 Share on other sites More sharing options...
jonoc33 Posted October 13, 2007 Author Share Posted October 13, 2007 Replace: <?php while ($file = readdir($handle)) { $files[] = $file; } ?> with my code. Ken Found it . Thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/#findComment-368538 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.