Reading file names from a folder

Reply

Join Date: Feb 2006
Posts: 12
Reputation: seh1 is an unknown quantity at this point 
Solved Threads: 0
seh1 seh1 is offline Offline
Newbie Poster

Reading file names from a folder

 
0
  #1
Mar 15th, 2006
Hi,
I have a bunch of uploaded files in a folder. Now I want to be able to get the names of these files that are stored in the folder using PHP so that can I create direct links to each file from my page. ie can PHP read the names of files from a folder?

Thanks,
Sean
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Reading file names from a folder

 
0
  #2
Mar 15th, 2006
  1. <?php
  2. $dir = ".";
  3.  
  4. $dh = opendir($dir);
  5.  
  6. while (($file = readdir($dh)) !== false) {
  7. echo "<A HREF=\"$file\">$file</A><BR>\n";
  8. }
  9.  
  10. closedir($dh);
  11. ?>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC