list of files in a web folder

A

Amanda H

I want to create a web page that lists all the files in a folder-
specifically for photos and video, so that I can just dump a video into the
video folder in my website and it shows up on the video list web page.

I've experimented with the FileSystemObject, but this seems to need absolute
path names, and I'm looking for something simpler with relative path names.

Any suggestions?

Thanks, Amanda
 
S

Steven Burn

strPath = Request.Querystring("f")

'// If the querystring is blank, set the path to the current dir
If strPath <> "" Then strPath = "./"

Dim objFSO, objFl, objFldr
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFldr = objFSO.GetFolder(Server.MapPath(strPath))
For Each objFl in objFldr.Files
Response.Write objFl.Name & " - " & objFl.Size & "b<br>"
Next
Set objFSO = Nothing
Set objFldr = Nothing
Set objFl = Nothing

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
 
P

Phill. W

Amanda H said:
I want to create a web page that lists all the files in a folder-
specifically for photos and video, so that I can just dump a video
into the video folder in my website and it shows up on the video
list web page.

One really, /really/ simple, if [possibly] dangerous and [definitely]
un-pretty solution :

Allow Directory Browsing in your video folder.

That way, you just type in the URL of the /folder/ and you'll get
a [default] directory listing automatically; no code required.

Alternatively (because you'll get fed up with the limitations of that
solution fairly quickly), yes; the FSO does need full paths, but you
can translate relative ones /into/ full ones, using the Server objects
MapPath() method, as in

If oFSO.FileExists( Server.MapPath( "./videos/abc.def" ) ) Then

HTH,
Phill W.
 
V

Veign

Checking the length of strPath is more efficient (have heard by as much as
25%) than comparing to an empty string....

Like:
If Len(strPath) = 0 Then strPath = "./"

Just a quick FYI
 
L

ljb

Amanda H said:
I want to create a web page that lists all the files in a folder-
specifically for photos and video, so that I can just dump a video into the
video folder in my website and it shows up on the video list web page.

I've experimented with the FileSystemObject, but this seems to need absolute
path names, and I'm looking for something simpler with relative path names.

Any suggestions?

Thanks, Amanda

DirList.ASP will list all the files and allow you to change the sort order.
Find the source code at http://www.romankoch.ch/capslock/standaloners.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top