listing folder contents in a browser (Full Version)

All Forums >> [Web Development] >> Server Issues



Message


nickhurd -> listing folder contents in a browser (3/14/2005 18:08:13)

I'm running a windows server and trying to give a user permissions to see the contents of a folder. Something like www.site.com/folder

Is there any way to make only that folder browsable? Permissions at the folder level don't seem to work. I get access forbidden even if I'm loggin in on the administrator account

I don't want the entire site to be browsable.

Thanks,
Nick Hurd
Litening Software




Giomanach -> RE: listing folder contents in a browser (3/14/2005 19:57:34)

Nick

Windows OS Version? IIS? Apache? Xitami?

Using ASP, PHP, CFM? etc etc

We need more details to give you an answer




nickhurd -> RE: listing folder contents in a browser (3/15/2005 17:45:08)

I didn't give quite enough information, did I.

Windows 2003 Web Server. Asp is available.




Giomanach -> RE: listing folder contents in a browser (3/15/2005 19:40:15)

OK, create an ASP page, with this in it:

<%
'Putting this file into a directory and calling it will list all the files in the directory as text links with
'relative paths
dim FileExt(3)
dim AbsolutePath
dim Max
'FileExt Holds File Extension, to add new file ext write
'FileExt(4)="gif"
'then change the array dim stat. to 4 and etc...
FileExt(0)="txt"
FileExt(1)="htm"
FileExt(2)="html"
FileExt(3)="asp"
Max=UBound(FileExt)
AbsolutePath = Server.MapPath ("/")
ShowFolderList AbsolutePath

Sub ShowFolderList(FldPath)
Dim fso, f, f1, s, sf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(FldPath)
Set sf = f.SubFolders
For Each f1 in sf
s = FldPath & "\" & f1.name
ShowFiles s
Next
End sub

Sub ShowFiles(path)
dim fs,Dir,n,file
set fs=server.CreateObject("Scripting.FileSystemObject")
Set Dir=fs.GetFolder(path & "\")
for each file in dir.files
for n= 0 to Max
if Right(file,len(FileExt(n)))=FileExt(n) then
MakeLink file
end if
next
next
ShowFolderList path
end sub

Sub MakeLink(path)
dim Link
path=Mid(path,Len(AbsolutePath)+1)
path=Replace(path,"\","/",1)
file=path
link="<a href=" & chr(34) & file & chr(34) & " title=" & file & ">" & file & "</a><br>"
Response.Write link
end sub
%>


That will should list the files, and provide a link to each of them.

HTH

Dan




rdouglass -> RE: listing folder contents in a browser (3/23/2005 11:25:10)

I posted a similar solution on this thread:

http://www.frontpagewebmaster.com/m-258796/tm.htm




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875