|
rdouglass -> RE: Server 2003 won't download files (7/7/2006 16:11:25)
|
I would suggest checking permissions on/in those files/folders and ensure the IUSR_machinename has at least read privs. As to the dynamic listing, here is a very stripped down version of a page I use to list all files of certain extensions. <%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit
On Error Resume Next
' declare variables
Dim objFSO, objFolder
Dim objCollection, objItem
Dim strPhysicalPath, strTitle, strServerName
Dim strPath, strTemp, foldName, foldTemp
Dim strName, strFile, strExt, strAttr, strDisplay
Dim intSizeB, intSizeK, intAttr, dtmDate
' declare constants
Const vbReadOnly = 1
Const vbHidden = 2
Const vbSystem = 4
Const vbVolume = 8
Const vbDirectory = 16
Const vbArchive = 32
Const vbAlias = 64
Const vbCompressed = 128
' don't cache the page
Response.AddHeader "Pragma", "No-Cache"
Response.CacheControl = "Private"
' get the current folder URL path
strTemp = Mid(Request.ServerVariables("URL"),2)
strPath = ""
Do While Instr(strTemp,"/")
foldTemp = Left(strTemp,Instr(strTemp,"/"))
strPath = strPath & Left(strTemp,Instr(strTemp,"/"))
strTemp = Mid(strTemp,Instr(strTemp,"/")+1)
Loop
foldName = Right(foldTemp,Instr(foldTemp,"/"))
foldName = Left(foldName,Len(foldName)-1)
strPath = "/" & strPath
' build the page title
strServerName = UCase(Request.ServerVariables("SERVER_NAME"))
strTitle = "Contents of the " & foldName & " folder"
' create the file system objects
strPhysicalPath = Server.MapPath(strPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
%>
<html>
<head>
<title>File Listings</title>
</head>
<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" bgcolor="#FFFFDD">
<div align="left">
<table border="0" cellspacing="1" width="100%">
<tr>
<td width="100%">
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top" align="left">
<div align="left">
<h4 align="center"><font face="Arial" size="4">File Listing:</font></h4>
<br><table width="100%" border="1" cellspacing="1" cellpadding="2">
<tr>
<th align="left"><font face="Arial" size="3">Name</font></th>
<th align="left"><font face="Arial" size="3">File Date</font></th>
</tr>
<%
''''''''''''''''''''''''''''''''''''''''
' output the folder list
''''''''''''''''''''''''''''''''''''''''
Set objCollection = objFolder.SubFolders
For Each objItem in objCollection
strName = objItem.Name
strAttr = MakeAttr(objItem.Attributes)
dtmDate = CDate(objItem.DateLastModified)
%>
<% If (Left(strName,1) <> "_") then %>
<tr>
<td align="left"><b><a href="<%=strName%>"><font face="Arial" size="3"><%=strName%></font></a></b></td>
</tr>
<% end if%>
<% Next %>
<%
''''''''''''''''''''''''''''''''''''''''
' output the file list
''''''''''''''''''''''''''''''''''''''''
Set objCollection = objFolder.Files
For Each objItem in objCollection
strName = objItem.Name
strFile = Server.HTMLEncode(strName)
intSizeB = objItem.Size
intSizeK = Int((intSizeB/1024) + .5)
If intSizeK = 0 Then intSizeK = 1
strAttr = MakeAttr(objItem.Attributes)
strName = Ucase(objItem.ShortName)
If Instr(strName,".") Then strExt = Right(strName,Len(strName)-Instr(strName,".")) Else strExt = ""
dtmDate = CDate(objItem.DateLastModified)
strDisplay = Left(strFile,((len(strFile))-4))
%>
<% If (strExt="PDF") or (strExt="DOC") or (strExt="XLS") or (strExt="HTM") then %>
<tr>
<td align="left"><a href="<%=strFile%>" target="_blank"><font face="Arial" size="3"><%=strDisplay%></font></a></td>
<td align="left"><%=FormatDateTime(dtmDate,vbShortDate)%></td>
</tr>
<% end if %>
<% Next %>
<tr>
<td>
<font face="Arial" size="2"><input type="button" value="Exit" name="B3" onClick="window.close()"></font>
</td>
</tr>
</table> </div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
Save this code on an ASP page and drop it into any folder and browse to it. I currently restrict if to Acrobat, Word, Excel, and HTML pages with the line: <% If (strExt="PDF") or (strExt="DOC") or (strExt="XLS") or (strExt="HTM") then %> but you can change that to any file extensions you choose. Hope it helps.
|
|
|
|