Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   list of files in a web folder (http://www.velocityreviews.com/forums/t797979-list-of-files-in-a-web-folder.html)

Amanda H 02-18-2005 02:04 PM

list of files in a web folder
 
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



Steven Burn 02-18-2005 02:32 PM

Re: list of files in a web folder
 
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!

"Amanda H" <amanda2@southwind.org> wrote in message
news:zBmRd.1097$Yf5.337463@twister.southeast.rr.co m...
> 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
>
>




Phill. W 02-18-2005 04:18 PM

Re: list of files in a web folder
 
"Amanda H" <amanda2@southwind.org> wrote in message
news:zBmRd.1097$Yf5.337463@twister.southeast.rr.co m...
> 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.



Veign 02-18-2005 09:24 PM

Re: list of files in a web folder
 
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

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

"Steven Burn" <somewhere@in-time.invalid> wrote in message
news:OLWQVbcFFHA.3728@TK2MSFTNGP14.phx.gbl...
> 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!
>
> "Amanda H" <amanda2@southwind.org> wrote in message
> news:zBmRd.1097$Yf5.337463@twister.southeast.rr.co m...
> > 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
> >
> >

>
>




ljb 02-21-2005 04:36 PM

Re: list of files in a web folder
 

"Amanda H" <amanda2@southwind.org> wrote in message
news:zBmRd.1097$Yf5.337463@twister.southeast.rr.co m...
> 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




All times are GMT. The time now is 05:56 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.