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? 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. 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? 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 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. 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 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 Link to comment https://forums.phpfreaks.com/topic/73074-solved-directory-listing/#findComment-368538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.