p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP 3.0 (http://p2p.wrox.com/forumdisplay.php?f=27)
-   -   Can anyone tell me what's wrong with this code? (http://p2p.wrox.com/showthread.php?t=26369)

hobgoblin March 3rd, 2005 01:47 PM

Can anyone tell me what's wrong with this code?

Apologies in advance to anyone who thinks that I'm one of those people who starts multiple threads about the same problem, but my other posting was more by way of a reply to the otehr poster's query, rather than a plea for help with my problem.

Anyway, I have a web site onto which I'd like to put some confidential documents (mainly MS Word and PDF files) and have them only accessible to persons who have logged in.

I already have the login processes sorted out. What I am having trouble with is adapting the chapter 10 code to give a directory listing of my 'private' files, and enable my authorised members to download them by clicking on their names.

My web server's folder tree looks like this:

---|--htdocs---|--index.asp |---file1
   | |--members-----------|---file2
   | |--files... |---DisplayDirectory.asp
   | |--morefiles...
   | |--otherdir----------|---files...
   | |---morefiles...
   | |---evenmorefiles...

OK, so I have my modified bit of Wrox code from Chapter 10 in the 'members' folder, and my 'private' files in the private directory (which is inaccessible by entering a URL). My modified code can display a directory listing of the /private folder, but I can't figure out how to make the server deliver the files from the /private folder when the links are clicked. What ssems to happen when the links are clicked is that the server tries to fins a file with that name in the /htdocs/members folder (i.e. where the DisplayDirectory.asp file lives).

How do I make the server fetch the files from /private?

Here's my code:

<TITLE>Display Directory (modified)</TITLE>

  Dim strPhysicalPath
  strPhysicalPath = Server.MapPath("../../private/dummy.asp")

  Dim objFSO, objFile, objFileItem, objFolder, objFolderContents
  Set objFSO = CreateObject("Scripting.FileSystemObject")

  Set objFile = objFSO.GetFile(strPhysicalPath)
  Set objFolder = objFile.ParentFolder
  Set objFolderContents = objFolder.Files

<TABLE cellpadding=5>
<TR align=center>
  <TH align=left>File Name</TH>
  <TH align=left>File Type</TH>
  <TH>File Size</TH>
  <TH>Last Modified</TH>

  For Each objFileItem In objFolderContents
  if objFileItem.Name="dummy.asp" Then
      <TD align=left>
      <A HREF="<%= objFileItem.Name %>"><%= objFileItem.Name %></A>
      <TD align=right>
      <%= objFileItem.type %>
      <TD align=right>
      <%= objFileItem.size %>
      <TD align=right>
      <%= objFileItem.DateLastModified %>
  End If


Thanks in advance for any assistance


All times are GMT -4. The time now is 05:57 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.