472,802 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,802 software developers and data experts.

Get a list of files on a website

Greetings,

I need to get a list of all files in a particular virtual directory on
a web site, such as -
http://www.myServer.com/FileStore

I tried using the directory functions, but this doesn't work.

if($dirHandle = opendir("http://www.myServer.com/FileStore/"))
{
while(false !== ($file = readdir($dirHandle)))
{
print($file."<br>");
}
}
closedir($handle);
}

Is there a way to do this?

Thanks,
Harold

Jul 17 '05 #1
3 20941
"Harold Crump" <or**********@yahoo.com> wrote in
news:11**********************@f14g2000cwb.googlegr oups.com:
Greetings,

I need to get a list of all files in a particular virtual directory on
a web site, such as -
http://www.myServer.com/FileStore

I tried using the directory functions, but this doesn't work.

if($dirHandle = opendir("http://www.myServer.com/FileStore/"))
{
while(false !== ($file = readdir($dirHandle)))
{
print($file."<br>");
}
}
closedir($handle);
}

Is there a way to do this?


opendir is meant to be used on the same server on which the script is
running.

you can't just connect to any website folder on the internet and download
everything in it!!
Jul 17 '05 #2
NC
Harold Crump wrote:

I need to get a list of all files in a particular virtual
directory on a web site, such as -
http://www.myServer.com/FileStore

I tried using the directory functions, but this doesn't work.
Directory functions only work on local file systems, not
over HTTP. This is clearly spelled out in the PHP Manual.
Is there a way to do this?


Yes, but only under two conditions (both are required):

1. There is no directory index in the target directory, and
2. The HTTP server on the remote system is allowed to
provide the directory listing in response to a request
for the directory name.

In Apache, the name of the directory index is set by the
DirectoryIndex directive. To allow listing the contents
of the directory, you should specify the Options Indexes
directive.

Cheers,
NC

Jul 17 '05 #3
NC wrote :
Harold Crump wrote:

I need to get a list of all files in a particular virtual
directory on a web site, such as -
http://www.myServer.com/FileStore

I tried using the directory functions, but this doesn't work.


Directory functions only work on local file systems, not
over HTTP. This is clearly spelled out in the PHP Manual.
Is there a way to do this?


Yes, but only under two conditions (both are required):

1. There is no directory index in the target directory, and
2. The HTTP server on the remote system is allowed to
provide the directory listing in response to a request
for the directory name.

In Apache, the name of the directory index is set by the
DirectoryIndex directive. To allow listing the contents
of the directory, you should specify the Options Indexes
directive.

Cheers,
NC


Even with these two conditions met, how would the php script know what
the files are? Wouldnt the return result just be an HTML page with <a>
tags that may or may not be links to files?

The web server software "apache", "IIS", etc would each spit out the
directory listing differently. However, all in HTML.

I would have thought the only way to do this would be to an FTP server.

--
if the oil light is on, dont think it will just go away

Jul 17 '05 #4

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

Similar topics

5
by: LarryM | last post by:
Hi, This is maybe not a pure ASP question, but has some relation: Please help me throw some light on this: Which directories and files are visible and readable for a (hacking) user at a...
8
by: Opa | last post by:
Hi, Does anyone know how to get a list of files for a given directory from a given url. I have the following, but get an error indicating that URI formats are not supported. ...
1
by: Marc Pelletier | last post by:
Hello all, I am a desktop programmer getting my feet wet on the web. I am trying to build a .net website that will keep a set of local files synchronized with a master set on the web. Using a...
9
by: Marco Castro | last post by:
I tried to google for information of what the output of the "LIST" command means but couldn't find any articles that tell me exactly what every character means. I can figure out most of it, its...
2
by: AAJ | last post by:
Hi all I have a few questions about file locations with VS2005, localhost WidowsXP and remotehost Server2003, and I wonder if anyone can help me get started 1) If I build a web site on my...
4
by: AAJ | last post by:
Hi all Is it possible to programatically list all the .aspx files within the currenty running website. e.g. something like foreach {aspxfile in AllaspxFilesInMyProject) { string filename =...
1
by: aaapaul | last post by:
What is the best way to transfer the necessary files of a website to the webserver. In VS2003 there was a possibility to say Project copy -only files, which are necessary for running ! I...
0
by: Jeremy | last post by:
We have files arriving via ftp to a server which is on a different domain than the intranet webserver. I want to be able to manipulate these files from the website. Both domains are within the...
3
by: saurabhthakur | last post by:
hello, i am using .net 1.1,vb ,i have 2 web applications.one is installed in client side server which is currently working offline(intranet)..other is at my side which is online website.frequently i...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.