How to list the contents of a folder on an ASP page and make the list clickable.

M

mallyonline

Thank you for your previous help.



I posted regarding listing the names of files held in a folder on the server
and making the

list appear clickable. This has now been accomplished. The files are
listed - The files are clickable -



There would appear to be a problem now in that the files do not open and run
as they otherwise would do on any standard directory browsing page.



When the link is clicked, rather than open the file and play in a media
player what actually happens is a new browser window tries to open
objFl.Name which obviously it cannot.



The Work Around:

I now have the server open a new window that allows directory browsing. This
is just a temporary measure to get a list of files that open in any media
player. I would obviously like it if the code would open a media player
possibly even in a new frame this would allow me to see the files and have
them play in another frame at the same time as browsing.



I have posted this message before and received no reply so I am apologizing
in advance for this; however since I have not had a reply I felt it
necessary to post again to the group.



The code: I have decided to leave the code out of this message. What I will
say is that anyone who has a genuine interest in what I am trying to achieve
here is free to post there interest / or email me in private to
(e-mail address removed)



If you could help on this I would be much appreciative.

Kind Regards

Malcolm
 
C

Curt_C [MVP]

Sadly, you'll have to show the code, but really only the lines that write the
link to the page.

Most likely you are "" (quoting) it incorectly so you are getting the
literal objName instead of the value.
 
M

mallyonline

Thank you for showing your interest.

Keeping in mind that i have made changes to allow for the page to be browsed
by directory from the server.(IIS6)

The Code:
<%
Dim objFSO,objFldr,objFl, sPath
sPath = "Local Drive:\Inetpub\wwwroot\folder contents"
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objFldr=objFSO.GetFolder(sPath)
For Each objFl in objFldr.Files
'Print the name of all files in the folder

Response.Write "<a href=""mp3/"" target=""_main"">" & objFl.Name & "</a><br
/>"
Next
Set objFldr=Nothing
Set objFSO=Nothing
%>
 
B

Bob Lehmann

I don't do the double quote thing - too confusing keeping track of them,
but....
Response.Write "<a href='mp3/" & objFl.Name & "' target='_main'>" &
objFl.Name & "</a><br/>"

The filename needs to be part of the href attribute.

Bob Lehmann

mallyonline said:
Thank you for showing your interest.

Keeping in mind that i have made changes to allow for the page to be browsed
by directory from the server.(IIS6)

The Code:
<%
Dim objFSO,objFldr,objFl, sPath
sPath = "Local Drive:\Inetpub\wwwroot\folder contents"
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
Set objFldr=objFSO.GetFolder(sPath)
For Each objFl in objFldr.Files
'Print the name of all files in the folder

Response.Write "<a href=""mp3/"" target=""_main"">" & objFl.Name &
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top