How to read a Dir and covert it to a list that can be downloaded from a browser

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-01-2006
Dave
 
Posts: n/a
Default How to read a Dir and covert it to a list that can be downloaded from a browser

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
Reply With Quote
  #2 (permalink)  
Old 10-01-2006
ZeldorBlat
 
Posts: n/a
Default Re: How to read a Dir and covert it to a list that can be downloaded from a browser


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>

Reply With Quote
  #3 (permalink)  
Old 10-01-2006
Gleep
 
Posts: n/a
Default Re: How to read a Dir and covert it to a list that can be downloaded from a browser

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);
Reply With Quote
  #4 (permalink)  
Old 10-03-2006
.:[ ikciu ]:.
 
Posts: n/a
Default Re: How to read a Dir and covert it to a list that can be downloaded from a browser

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();


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:55 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0