A guy called Juan Manuel Bellina from Buenos Aires in Argentina that I met in CyberSpace asked me if I coould tell him him how to use IIS to list the PDF files on one of his web sites and then to allow clients to select and view the one of their choice.
I prepared an example
I did not have a place that contains PDF files, so I did id for HTM files (all that he needs to do is to change the "HTM" to "PDF" in the listings below.
First, you need to know the "Real" definition of the folder where your files reside on your WebServer. Although I have never suffered the problem, several folk have told me that their ISP's are very reluctant to give this information. So if you upload the file below as mappath.asp to your webserver and then try it, you will see the answer
<% Set objFS=Server.CreateObject("Scripting.FileSystemObject") strFileName = Server.MapPath("mappath.asp") Response.Write strFileName %>
Once you have got that, then you can modify the code below and it will provide you with a page giving the list and links
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>FILE INFO LIST</title> </head> <body> <table border> <tr> <td>File Name</td> <td>Date Created</td> <td>Date Last Accessed</td> <td>Date Modified</td> </tr> <% urlRoot = "http://www.mysite.com/" folderspec = "C:\INETPUB\WWWROOT\MYSITE" Set ffso = CreateObject("Scripting.FileSystemObject") Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(folderspec) Set fc = f.Files For Each f1 in fc cFile = f1.name cExt = UCase(Right(cFile, 4)) if (cExt = ".HTM") then s = "<tr><td><a href='" & cFile & "' target=_blank>" & cFile & "</a></td>" filespec = "C:\INETPUB\WWWROOT\MYSITE\" & cFile Set ff = ffso.GetFile(filespec) s = s & "<td>" & ff.DateCreated & "</td>" s = s & "<td>" & ff.DateLastAccessed & "</td>" s = s & "<td>" & ff.DateLastModified & "</td>" s = s & "</tr>" & VbCrLf Response.Write s end if Next %> </table> </body> </html>For the sake of completeness you can see (a cut down version of) the file that is generated by the above file Click here
Now there - aint that simple !!
I do hope that it has been interesting or of benefit to you.