Link to home
Start Free TrialLog in
Avatar of tom12ga
tom12gaFlag for United States of America

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
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rangasuman
rangasuman

If you are looking for a Javascript solution you can try to use JS ActiveX extensions

document.write("Contents of " + getCurrentFolder());

fileName = findFirstFile("*.pdf");
while(fileName.length)
{
    document.write("<a href=" + fileName + ">" + fileName + "</a>");
    fileName = findNextFile();
}
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("Scripting.FileSystemObject")
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
Avatar of tom12ga

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..."