473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

list documents in a html table

Ken
I currently have a set of documents in a directory that i need to list in a
html table. Is there any way to generate the table with the documents listed
instead of having to update the table manually everytime a new document is
added to the list.

Thanks
Ken
Jul 19 '05 #1
5 2738
Where is this directory? Is it on the IIS server? I'm going to assume for
the moment that the directory is on the IIS server. There are at least two
options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.). If
you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFiles = oFSO.GetFolder("D:\PathOnServer").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Name%></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous
access on your site (default).

Ray at work

"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
I currently have a set of documents in a directory that i need to list in a html table. Is there any way to generate the table with the documents listed instead of having to update the table manually everytime a new document is
added to the list.

Thanks
Ken

Jul 19 '05 #2
Ken,

How about you save them in a database table.

Quewry your table and loop through each record
interweaving it with HTML and that would save you
changing your HTML code each time.
-----Original Message-----
I currently have a set of documents in a directory that i need to list in ahtml table. Is there any way to generate the table with the documents listedinstead of having to update the table manually everytime a new document isadded to the list.

Thanks
Ken
.

Jul 19 '05 #3
Ken
Thanks for the response.
This is just what I need. One more question. How can I create a link to the
files after they are listed so that they can be opened up?

Thanks again
Ken
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:um*************@TK2MSFTNGP11.phx.gbl...
Where is this directory? Is it on the IIS server? I'm going to assume for the moment that the directory is on the IIS server. There are at least two options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.). If you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFiles = oFSO.GetFolder("D:\PathOnServer").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Name%></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous
access on your site (default).

Ray at work

"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
I currently have a set of documents in a directory that i need to list in
a
html table. Is there any way to generate the table with the documents

listed
instead of having to update the table manually everytime a new document

is added to the list.

Thanks
Ken


Jul 19 '05 #4
Generate the HTML that would provide a link. What do you want the resultant
HTML to look like? You'd want it to look like:
<td><A href="filex.doc">filex.doc</a></td>

right? What is filex.doc? It's the current .Name property of the current
file while looping. So, to get that resultant HTML, you'd do:
'''other code
For Each oFile in oFiles
%>
<tr>
<td><A href="<%=oFile.Name%>"><%=oFile.Name%></A></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next
'''other code
Ray at work


"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uq**************@TK2MSFTNGP11.phx.gbl...
Thanks for the response.
This is just what I need. One more question. How can I create a link to the files after they are listed so that they can be opened up?

Thanks again
Ken
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:um*************@TK2MSFTNGP11.phx.gbl...
Where is this directory? Is it on the IIS server? I'm going to assume for
the moment that the directory is on the IIS server. There are at least

two
options. 1 is to just enable directory browsing for the directory and not
have a default page for the directory (default.htm, default.asp, etc.).

If
you'd like to make things prettier, you can use the FSO and do something
like:

<table>
<tr>
<td>File name</td>
<td>Last modified</td>
</tr>

<%
Dim oFSO, oFiles, oFile
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFiles = oFSO.GetFolder("D:\PathOnServer").Files
For Each oFile in oFiles
%>
<tr>
<td><%=oFile.Name%></td>
<td><%=oFile.DateLastModified%></td>
</tr>
<%
Next

Set oFiles = Nothing
Set oFSO = Nothing
%>
</table>

IUSR will need permission to read the directory if you're using anonymous access on your site (default).

Ray at work

"Ken" <kl*****@spamfreeingr.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
I currently have a set of documents in a directory that i need to list

in
a
html table. Is there any way to generate the table with the documents

listed
instead of having to update the table manually everytime a new

document is added to the list.

Thanks
Ken



Jul 19 '05 #5
On Tue, 22 Jul 2003 10:36:25 -0500, "Ken" <kl*****@spamfreeingr.com>
wrote:
I currently have a set of documents in a directory that i need to list in a
html table. Is there any way to generate the table with the documents listed
instead of having to update the table manually everytime a new document is
added to the list.


Here's how we serve up files from a folder dynamically:

<%
dim StringLength
dim TemporaryName
dim DisplayName
dirtowalk="/documents"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
response.write "<UL>"
For Each FileName in fc
StringLength = Len(FileName.name)
StringLength = StringLength - 4
TemporaryName = Left(FileName.name,StringLength)
DisplayName = Replace(TemporaryName,"_"," ")
response.write "<LI><A HREF='/documents/"
response.write FileName.name
response.write "'>"
response.write DisplayName
response.write "</A><br>"
Next
response.write "</UL>"
%>

No table, just a list of files without extensions, automatically
linked to the files. We normally publish in PDF format, try this link
for the end result:

http://manager.naplesgov.com/updates/2003.asp

I use this snippet quite a few places to serve up a list of documents
dynamically, but don't blame me for the code. I picked it up quite a
while ago and I'd credit the original author if I knew who it was.
Though I'm the one to blame for making the display pretty. :)

The code displays the file name, replacing underscores with spaces.
So we put the files to be served in the folder like this:

This_is_a_file.pdf
Here_is_Another.pdf

And so on. Adding table code into the loop isn't hard, something
like:

<%
dim StringLength
dim TemporaryName
dim DisplayName
dirtowalk="/documents"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(server.mappath(dirtowalk))
Set fc = f.Files
response.write "<TABLE CELLPADDING=2>"
For Each FileName in fc
StringLength = Len(FileName.name)
StringLength = StringLength - 4
TemporaryName = Left(FileName.name,StringLength)
DisplayName = Replace(TemporaryName,"_"," ")
response.write "<TR><TD><A HREF='/documents/"
response.write FileName.name
response.write "'>"
response.write DisplayName
response.write "</A></TD></TR>"
Next
response.write "</TABLE>"
%>

Change the dirtowalk variable to whatever directory you'll be using as
well as the appropriate HREF path.

Hope it helps.

Jeff
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Neil Varshneya | last post by:
Hi, I'm looking for an html code list that contains all html codes and their effects. If all of you smart people who read this article know where such a list is please post a follow-up message to...
9
by: Stephen Tyndall | last post by:
This is the updated version of the resources list posted last month. Updates: -Now application-neutral. The old list had video game-related programming books. -Required reading section added....
33
by: abs | last post by:
Hi all. My list: <ul> <li id="a" onclick="show(this)">Aaaaaaaa</li> <li id="b" onclick="show(this)">Bbbbbbbb</li> <li id="c" onclick="show(this)">Cccccccc <ul> <li id="d"...
12
by: enak | last post by:
I have found some code that shows how to convert an html form to Word. The message said to simply put the following in the Page_load: Response.ContentType = "application/ms-word"...
69
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000);...
9
by: Thomas Ploch | last post by:
Hello fellow pythonists, I have a question concerning posting code on this list. I want to post source code of a module, which is a homework for university (yes yes, I know, please read...
2
by: Lysander | last post by:
I have not seen this feature documented before, so I thought I would share it with you, as I will be using it in a later article. For a combo or list box, the source data is normally a...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.