I have very little background in website programming so I apologise if this might be an obvious question.
I am updating some pages on a website using ASP. On a particular page, I have a list of pdf files that people can download. Currently, the title of the file is written in directly onto the page along with a link to it
myPage.asp
<tr>
<td>Title</td>
<td><a href="something.pdf">PDF</a></td>
</tr>
I wanted to collect all the titles and filenames into one table, for example:
FileCode Title Filename
001 ABC abcfile.pdf
002 XYZ xyz.pdf
So that when I am populating the page I can use something like the following,
<tr>
<td>Table(code).Title</td>
<td><a href=Table(code).Filename>PDF</a></td>
</tr>
The code doesn’t have to look like that (I don’t know what it will look like); this is just an example to show what I mean: I want to be able to keep all the file information in one location so it is easy to update and add things to it, and I can just reference it when I need to display some information.
The reason I am doing this is because I don’t want the user to be able to directly click the pdf link and get the file; they must go through a contact form to get the file and I thought it might be easier to just send a file code instead of the actual filename,
<a href="contactForm.asp?code=001">PDF</a>
So this table will be accessed by contactForm.asp as well. Hence I wanted a central location for such a table and I didn’t know what are the acceptable conventions for websites.
The simplest solution would be to store the files in an array in an ASP include file, like this:
files.asp
(if the files are in a folder you would add the path, eg “/folder/file1.txt”)
To display a list of files you could use this code:
showfiles.asp
And to send the file to the browser you could use one of the following methods. The first one is just a simple redirect to the file, and the second actually loads the file and writes the file to the browser so that the user does not know the path to the file (more secure but not very secure):
contact.asp
contact2.asp
Hopefully you can use some of this to make what you need?