473,466 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Directory Listing ...

I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.

Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?

That would be a great help.

Many thanks,
Alan Searle
Jul 17 '05 #1
3 2174
a
Alan Searle wrote:
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.

Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?

That would be a great help.

Many thanks,
Alan Searle


http://www.php.net/dir
Jul 17 '05 #2
On Wed, 30 Jun 2004 11:52:18 -0400
Alan Searle <aj*******@xxxxyahoo.com> wrote:
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I

want to load the list of files in the program's current directory into
an array).


You can scan a directory with

$handle = opendir("somedirectory");
while($filename = readdir($handle))
$fileslist[] = $filename;
closedir($handle);

In PHP5 there seems to be a single function scandir() which does
exactly what you want.

Greets,
Andreas

--
tcp/80 http://andreas.slashdot.ch
tcp/25 an*****@slashdot.ch
tcp/6667 irc.slashdot.ch #garbage
Jul 17 '05 #3
In article <cb**********@newsreader2.netcologne.de>, Alan Searle wrote:
I'm a newbie to PHP and need to be able to get a list of the
files/sub-directories from a particular directory on the server (ie: I
want to load the list of files in the program's current directory into
an array).

This must be possible but somehow I can't find the syntax in my
documentation.
It's in the http://www.php.net/manual.
Can someone send me a snippet of syntax? Or point me towards a good
'howto' that maybe has a catalogue of PHP commands?


Have a look in the archives of this group. It has been posted here this
week already. And probably many times before...

--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dean | last post by:
Hi I've got a question relating to using Javascript on an Intranet. I have a directory with a list of files in the format week36.xls, week37.xls and I want to write a script that will scan...
19
by: SU News Server | last post by:
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = listing =...
2
by: Tom | last post by:
I need to get a directory listing through http. If I put the directory path in the browser address bar such as http://somewebpage.com/subdir I get the listing of the directory. Of course this is...
8
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir)...
2
by: ngr | last post by:
I used to use the DirListox control in VB6 but this is no longer supported in VB.NET. What I want to do: I want to take a directory listing and show any subdirectories in a list. When you click...
8
by: dougawells | last post by:
Hi - I'm hoping for help with the auto-generation of a hyperlinked listing of all files in a directory. The server I use does not auto-generate this. So, when someone comes to this directory and...
7
by: epikto | last post by:
I have a mapped share that I am trying to get a listing of all the files that it contains. I use the following code to access the contents String files = Directory.GetFiles(path); I can then...
4
by: techusky | last post by:
I have a *very* simple script written that displays the directory listing of the current working directory, but I am having some difficulty when I try to change folders. Basically, I have my $dir...
2
by: marcusadeleon | last post by:
Hi, I was wondering how to open up a web directory to get a file listing. The directory I want to open allows directory listings, but has a directory password. Meaning it gives me a prompt to...
1
by: Steve | last post by:
My site is hosted on a Godaddy reseller site. Godaddy only allows the use of Curl to access remote sites. What is the method for listing a directory after connecting to the site with Curl? ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.