This is a discussion on How to read a Dir and covert it to a list that can be downloaded from a browser within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I would like to read all the files in a given DIR and create an array or some other way ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Dave wrote: > I would like to read all the files in a given DIR and create an array > or some other way so it can be listed in a web page and download... > Thanks > Dave Use scandir(): <http://www.php.net/scandir> |
|
|||
|
On 30 Sep 2006 18:07:34 -0700, "ZeldorBlat" <zeldorblat@gmail.com> wrote:
> >Dave wrote: >> I would like to read all the files in a given DIR and create an array >> or some other way so it can be listed in a web page and download... >> Thanks >> Dave > >Use scandir(): ><http://www.php.net/scandir> that's fine if you have php5 but if your isp is still using php4 try... $dirpath="path_to_my_dir"; $dh = @opendir ($dirpath); while ($file = @readdir ($dh)) { if(($file!="..")&&($file!=".")){ $entry = "$dirpath/$file"; $fileList[] = $entry; } } print_r($fileList); |
|
|||
|
Zebrawszy mysli Dave <first2try1@earthlink.net> wyklepal:
> I would like to read all the files in a given DIR and create an array > or some other way so it can be listed in a web page and download... PHP 5.x scandir() PHP 4.x if ($handle = opendir('/path/to/files')) { while (false !== ($file = readdir($handle))) { echo "$file\n"; } closedir($handle); } -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ikciu | gg: 718845 | www: www.e-irsa.pl 2be || !2be $this => mysql_query(); |