?
Solved

update link list when file is added.

Posted on 2014-08-25
7
Medium Priority
?
289 Views
Last Modified: 2014-08-29
I am neededing to create a web page that is essentially a list of files as hyperlink. I was wondering is there a way that when a file is added to the particular folder it would automatically get linked on the page?
0
Comment
Question by:jlcannon
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40283219
Would make more sense to store the file names in a db and build the page from the db
When a file is uploaded add a new entry to the db for it.
0
 
LVL 34

Accepted Solution

by:
Big Monty earned 1000 total points
ID: 40283276
You'll want to use the file system object, here's an example where it'll list all files in the current folder:


Dim strPathInfo, strPhysicalPath
  strPathInfo = Request.ServerVariables("PATH_INFO")
  strPhysicalPath = Server.MapPath(strPathInfo)

  Dim objFSO, objFile, objFileItem, objFolder, objFolderContents

  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Set objFile = objFSO.GetFile(strPhysicalPath)
  Set objFolder = objFile.ParentFolder
  Set objFolderContents = objFolder.Files
%>
<HTML>
 <HEAD>
  <TITLE>Display Directory</TITLE>
 </HEAD>
<BODY>
<TABLE cellpadding=5>
 <TR align=center>
  <td align=left>File Name</td>
  <td>File Size</td>
  <td>Last Modified</td>
</TR>
<%
  For Each objFileItem In objFolderContents
    Response.Write "<TR><TD align=left>"
    Response.Write objFileItem.Name 
    Response.Write "</TD><TD align=right>" 
    Response.Write objFileItem.Size 
    Response.Write "</TD><TD align=right>" 
    Response.Write objFileItem.DateLastModified 
    Response.Write "</TD></TR>"
  Next
%>

</TABLE>
</BODY>
</HTML>

Open in new window



Source:   http://p2p.wrox.com/classic-asp-professional/59514-asp-list-files-directory-dynamically.html
0
 

Author Comment

by:jlcannon
ID: 40283364
When I use the file system object i keep getting the following error:

Server.MapPath() error 'ASP 0171 : 80004005'

Missing Path

/technology/QCPlanIndex/QCPlanIndexStadeBeta.asp, line 7

The Path parameter must be specified for the MapPath method.



I am putting the network file path in here:

strPathInfo = Request.ServerVariables("\\Server\Folder")


Is this ocrrect?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Big Monty
ID: 40283467
can you confirm which of the options below pertains on where the folder is that you want listed:

1) the folder is the same where the page is loading from
2) the folder is within another folder from within your site
3) the folder is OUTSIDE of where your site runs from

Your line of code where you set the strPathInfo is indeed incorrect. The Request.ServerVariables object can only contain certain preset values. You can have a look here to understand how it's used.

if the folder you want listed somewhere within the site, then it'll be easy to set up, just post the relative url of the folder. If it's outside the site, the you'll need to create a virtual folder within your site to point to it, which is only a bit more complex to set up.
0
 

Author Comment

by:jlcannon
ID: 40283795
the folder is outside where the site runs.
0
 
LVL 34

Expert Comment

by:Big Monty
ID: 40283817
ok, then follow the directions in the link below to set up what's called a virtual directory (or folder):

http://msdn.microsoft.com/en-us/library/vstudio/bb763173(v=vs.100).aspx

This is for IIS7, if you have a different version, let me know and I'll get you instructions for it. once you have the virtual directory set up (don't forget to set the permissions as well), change your code from

strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)

Open in new window


to

  strPathInfo = "/nameOfVirtualDirectory/"
  strPhysicalPath = Server.MapPath(strPathInfo)

Open in new window

0
 
LVL 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1000 total points
ID: 40292203
>the folder is outside where the site runs.

If you just give permissions to the IIS_IUSER account, there is no need to make a virtual directory.  Once you do that, you can use fso to read the folders and / or files in that directory.   I do this for uploading files for instance.  When I upload a file, I move it outside the public www and use fso to save it and call it up later.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question