By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,686 Members | 2,708 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,686 IT Pros & Developers. It's quick & easy.

Trying to create hyperlinks

P: n/a
I am writing some code for an intranet and I need to be able to list the
files in folders and subfolders and display them in the browser window as
with hyperlinks.

I've picked up this very useful code on the internet from
www.4guysfromrolla.com. It works a treat, but one problem! If there is a
filename that contains a space, e.g., "my file.doc" the hyperlink only
links up to the space, e.g., it will hyperlink "my" and nothing else.

Here is the code which picks up file names without spaces and is called from
an HTML file as follows (maxitek being the name of my computer)
<a href="dir.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">dir.asp</a>

Sub Main()
Dim sPP, sUP, fso, f, fc, ff, fl
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
For Each fl in fc
Response.Write "<a href=" & sUP & fl.name & ">" & fl.name & "</a> <br>"
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Sub

Main()
%>
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"laura" <re*****@group.com> wrote in message
news:#H**************@tk2msftngp13.phx.gbl...
I am writing some code for an intranet and I need to be able to list the
files in folders and subfolders and display them in the browser window as
with hyperlinks.

I've picked up this very useful code on the internet from
www.4guysfromrolla.com. It works a treat, but one problem! If there is a
filename that contains a space, e.g., "my file.doc" the hyperlink only
links up to the space, e.g., it will hyperlink "my" and nothing else.

Here is the code which picks up file names without spaces and is called from an HTML file as follows (maxitek being the name of my computer)
<a href="dir.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">dir.asp</a>

Sub Main()
Dim sPP, sUP, fso, f, fc, ff, fl
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
For Each fl in fc
Response.Write "<a href=" & sUP & fl.name & ">" & fl.name & "</a> <br>"
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Sub

Main()
%>


Make sure the href val is quoted. I like to use single quotes in this case:

Response.Write "<a href='" & sUP & fl.name & "'>" & fl.name & "</a> <br>"

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserv...y/centers/iis/
http://mvp.support.microsoft.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
Jul 22 '05 #2

P: n/a
Tom,

YOU'RE WONDERFUL!!! Thank you so much!! It works.. stupid me for not
realising!

All the best
Laura
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
news:OK**************@TK2MSFTNGP09.phx.gbl...
"laura" <re*****@group.com> wrote in message
news:#H**************@tk2msftngp13.phx.gbl...
I am writing some code for an intranet and I need to be able to list the
files in folders and subfolders and display them in the browser window as
with hyperlinks.

I've picked up this very useful code on the internet from
www.4guysfromrolla.com. It works a treat, but one problem! If there is a
filename that contains a space, e.g., "my file.doc" the hyperlink only
links up to the space, e.g., it will hyperlink "my" and nothing else.

Here is the code which picks up file names without spaces and is called

from
an HTML file as follows (maxitek being the name of my computer)
<a href="dir.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">dir.asp</a>

Sub Main()
Dim sPP, sUP, fso, f, fc, ff, fl
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
For Each fl in fc
Response.Write "<a href=" & sUP & fl.name & ">" & fl.name & "</a>
<br>"
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Sub

Main()
%>


Make sure the href val is quoted. I like to use single quotes in this
case:

Response.Write "<a href='" & sUP & fl.name & "'>" & fl.name & "</a> <br>"

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserv...y/centers/iis/
http://mvp.support.microsoft.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running
IIS

Jul 22 '05 #3

P: n/a
http://www.powerasp.com/content/new/...hyperlinks.asp

"laura" <re*****@group.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I am writing some code for an intranet and I need to be able to list the
files in folders and subfolders and display them in the browser window as
with hyperlinks.

I've picked up this very useful code on the internet from
www.4guysfromrolla.com. It works a treat, but one problem! If there is a
filename that contains a space, e.g., "my file.doc" the hyperlink only
links up to the space, e.g., it will hyperlink "my" and nothing else.

Here is the code which picks up file names without spaces and is called
from an HTML file as follows (maxitek being the name of my computer)
<a href="dir.asp?PP=C:\Inetpub\wwwroot\&UU=//maxitek">dir.asp</a>

Sub Main()
Dim sPP, sUP, fso, f, fc, ff, fl
sPP = Request.QueryString("PP") 'Physical Path
sUP = Request.QueryString("UP") 'URL Path

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(sPP)
Set fc = f.Files
Set ff = f.SubFolders
For Each fl in fc
Response.Write "<a href=" & sUP & fl.name & ">" & fl.name & "</a> <br>"
Next
Set ff = nothing
Set fso = nothing
Set f = nothing
Set fc = nothing
End Sub

Main()
%>

Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.