Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 3rd, 2005, 01:47 PM
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can anyone tell me what's wrong with this code?

Hi,

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...
   |--private--|---privfile1.pdf
               |---privfile2.pdf
               |---privfile3.doc

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:

<HTML>
<HEAD>
<TITLE>Display Directory (modified)</TITLE>
</HEAD>
<BODY>

<%
  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>
</TR>


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

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

Thanks in advance for any assistance

H.



Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong with my code? DyerOppenheimer BOOK: Beginning Ajax with ASP.NET 0 January 7th, 2008 08:46 AM
What's wrong with this code? appleseed C++ Programming 2 November 25th, 2006 08:17 AM
What's wrong with this code? AlDugan XSLT 3 May 19th, 2006 12:06 PM
What is wrong with code? rtr1900 Classic ASP Databases 1 April 3rd, 2006 03:20 AM
what's wrong with this code? miguel.ossa ASP.NET 1.0 and 1.1 Basics 2 January 21st, 2004 11:33 AM





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