Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > BOOK: Beginning ASP 3.0
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #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?


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



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:00 PM.

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