View Full Version : Please Help With Hyperlinks

09-10-2004, 07:56 PM
Hello. I am new to this forum. I am not a web developer, but I am willing to learn. I am a network tech. So here is what I need to do: I need to be able to list and sort by date some files in a folder on another page. I also need the file names to be hyperlinked to the actual file so that the people can download the file.

Our emergency preparedness director will release press releases and put them in a folder. I need this page to update every time he puts something new in. I already found some code that will do everything that I need to do, except put the hyperlink back to the file. The code that I found can be seen here: http://www.aspfaqs.com/ASPScripts/P...Q.asp?FAQID=118. I have also attached the code in a txt file to this message.

If anyone can tell me what I need to do to get hyperlinks to work, I would appreciate it. Thank you.

Rusty Painter

Roy Sinclair
09-10-2004, 08:12 PM
Change just one line:

Response.Write " <TD>" & theFiles(i)(j) & "</TD>" & vbNewLine


Response.Write " <td><a href=""" & DIRECTORY & "/" & theFiles(i)(j) & """>" & theFiles(i)(j) & "</a></td>" & vbNewLine

09-10-2004, 09:21 PM
Roy, you are the man. Thank you. That worked. The only problem now is that every column is hyperlinked. Is there any way to just make the "File Name" column hyperlinked? If not, I can live with this. Thanks again. I have attached a screenshot of the webpage to show you what I am talking about.


Roy Sinclair
09-10-2004, 09:51 PM
Slight code change:

if j > 0 then
Response.Write " <TD>" & theFiles(i)(j) & "</TD>" & vbNewLine
Response.Write " <td><a href=""" & DIRECTORY & "/" & theFiles(i)(j) & """>" & theFiles(i)(j) & "</a></td>" & vbNewLine
end if

Restores the original line, except when it's the filename being displayed, then it adds the hyperlink.

09-11-2004, 01:37 AM
Thanks for all of your help. That is perfect. I might get this stuff one day.

09-15-2004, 01:56 PM
Hi there

Sorry to butt in here. I am having a problem getting this code to work. I have changed the line:

path = Server.MapPath(DIRECTORY)


path = Server.MapPath(C:/Documents)

but when I view the page there are no files listed. Does anyone know what I am doing wrong? The folder Documents has subfolders which in turn may have subfolders, is this the problem?

Any help greatly appreciated

09-15-2004, 02:44 PM
I just tried what you said. First you need to change:

path = Server.MapPath(C:/Documents)

back to:

path = Server.MapPath(DIRECTORY)

What you do change is on line 11 the CONST DIRECTORY. This needs to be a relative path.

Also, I tried to put a subfolder with some files in the directory. This did not show up. Only the files in the directory showed up.

Hope this helps.

09-15-2004, 02:57 PM
Thanks for the info. I have tried changing those lines and it still doesn't display anything so I will have to figure out a way to have it displaying the subfolders.

I have tried the code from the 'sticky' post above and it isn't doing it but it looks to be more what I need.

Oh well I'll keep trying.

Thanks again.