tom12ga
asked on
Automatically create hyperlinks of all files in a folder
I have a lot of PDF’s and I want to automatically link to them from a webpage. Does anyone know a quick way to automatically create hyperlinks on a webpage from the folder (full of PDF’s).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is how you do it in ASP. Of course you change the path in the fs.GetFolder to reflect the folder you want to use:
--- Example start ---
<html><head><title>PDF List</title></head>
<body>
<%
dim fs,fo,x
set fs=Server.CreateObject("Sc ripting.Fi leSystemOb ject")
set fo=fs.GetFolder("c:\")
for each x in fo.files
'Print the name and size of all files in the test folder
Response.write(x.Name & " (" & CLng(x.Size / 1024) & "kb) <br />")
next
set fo=nothing
set fs=nothing
%>
</body>
</html>
--- Example end ---
You can also see this question for some more information: https://www.experts-exchange.com/questions/21782165/How-to-find-the-size-of-the-PDF-Dynamically.html
--- Example start ---
<html><head><title>PDF List</title></head>
<body>
<%
dim fs,fo,x
set fs=Server.CreateObject("Sc
set fo=fs.GetFolder("c:\")
for each x in fo.files
'Print the name and size of all files in the test folder
Response.write(x.Name & " (" & CLng(x.Size / 1024) & "kb) <br />")
next
set fo=nothing
set fs=nothing
%>
</body>
</html>
--- Example end ---
You can also see this question for some more information: https://www.experts-exchange.com/questions/21782165/How-to-find-the-size-of-the-PDF-Dynamically.html
Alternatively, allow directory browsing in IIS or turn Indexing on in Apache.
This will automatically display a list of documents.
See example here: http://www.venera.com/downloads
ShalomC
This will automatically display a list of documents.
See example here: http://www.venera.com/downloads
ShalomC
ASKER
Thanks for all the info. The PHP code works pretty well but it was looking in the root for the links not the folder. Easy fix.
Did you see this comment?
"// change the path_to_pdf_dir to your directory..."
"// change the path_to_pdf_dir to your directory..."
document.write("Contents of " + getCurrentFolder());
fileName = findFirstFile("*.pdf");
while(fileName.length)
{
document.write("<a href=" + fileName + ">" + fileName + "</a>");
fileName = findNextFile();
}