Jag behöver använda IDG,s filhanterare och efter viss modifiering enligt detta forum och annan kod fungerar inte sidan om mappar har mellanslag och/eller filer innehåller mellanslag.
Set filsystemobjekt = CreateObject("Scripting.FileSystemObject")
Set folder = filsystemobjekt.GetFolder(StartMapp)
Set filer = folder.Files
Set underkataloger = folder.SubFolders
' Which Columns to display (True or False)
Const DisplayColumnName = True
Const DisplayColumnSize = True
Const DisplayColumnType = True
Const DisplayColumnModified = True
Const DisplayColumnSubItems = True
Function bytesize(bytes)
If bytes < 1024 Then
bytesize = "1 kB"
Else
bytesize = FormatNumber((bytes/1024),0,-1) & " kB"
End If
End Function
\<table border="0" width="100%"\>
\<tr\>
\<% If DisplayColumnName Then %\>
\<td bgcolor="#FFFFDF"\>Namn\</td\>
\<% End If %\>
\<% If DisplayColumnSize Then %\>
\<td bgcolor="#FFFFDF"\>Storlek\</td\>
\<% End If %\>
\<% If DisplayColumnType Then %\>
\<td bgcolor="#FFFFDF"\>Typ\</td\>
\<% End If %\>
\<% If DisplayColumnModified Then %\>
\<td bgcolor="#FFFFDF"\>Ändrad\</td\>
\<% End If %\>
</tr>
<tr>
<%
For Each folder in underkataloger
' Nedan kontrollerar vi så att det inte visas några mappar med konstiga attribut
Jag får det inte att fungera så jag gick ut på nätet och hittade en annan version.
Håll till godo och tack för hjälpen.
<%
'Set this to the home directory in relationship to the script.
'You cannot have the directory set to up one directory (ie "../") for security reasons unless you disable "Security" below.
'Note that if your file home directory is up one level the script may not function properly.
HomeDir = "files"
'Do not put a "/" on the end of this!
'Do not edit below this line unless you know what you're doing.
Security = "On"
'If you do not want users browsing directories up one level from the specified one, set this to "On".
'Otherwise, set it to "Off"
CurrentDir = Request.QueryString("dir")
if Left(CurrentDir, 3) = "../" and Security = "On" then
Response.Write "You are not permitted to browse this directory."
else
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
if CurrentDir = "" then
CurrentDir = HomeDir
Set BrowseContents = FSO.GetFolder(Server.MapPath(HomeDir))
else
Set BrowseContents = FSO.GetFolder(Server.MapPath(CurrentDir))
end if
Function bytesize(bytes)
If bytes < 1024 Then
bytesize = "1 kB"
Else
bytesize = FormatNumber((bytes/1024),0,-1) & " kB"
End If
End Function
' Which Columns to display (True or False)
Const DisplayColumnName = True
Const DisplayColumnSize = True
Const DisplayColumnType = True
Const DisplayColumnModified = True
Const DisplayColumnSubItems = True
%>
<html>
<head>
<title>Filhanteraren</title>
<link rel="stylesheet" type="text/css" href="mall.css">
</head>
<body bgcolor="#FFFFFF" text="#000000" vlink="#0000FF">
<table border="1" width="800">
<tr>
<td width="110"> </td>
<td>
Sökväg: <%=CurrentDir%><br>
<%
if not CurrentDir = HomeDir then
UpOneDirBegPos = InStrRev(CurrentDir, "/")
UpOneDirTotal = len(CurrentDir)
UpOneDirPath = Left(CurrentDir, UpOneDirBegPos - 1)
Response.Write "<b>«</b> <A HREF=""?dir=" & UpOneDirPath & """>Upp en nivå</A>"
end if
%>
<br><br>
<table border="1" width="100%">
<tr>
<% If DisplayColumnName Then %>
<td bgcolor="#FFFFDF">Namn</td>
<% End If %>
<% If DisplayColumnSize Then %>
<td bgcolor="#FFFFDF">Storlek</td>
<% End If %>
<% If DisplayColumnType Then %>
<td bgcolor="#FFFFDF">Typ</td>
<% End If %>
<% If DisplayColumnModified Then %>
<td bgcolor="#FFFFDF">Ändrad</td>
<% End If %>
</tr>
<%
for each BrowsedFolder in BrowseContents.SubFolders
if BrowsedFolder.Name <> "_vti_cnf" then
Response.Write "<tr>"
Response.Write "<td><IMG SRC=""images/Icon_Folder.gif""> <A HREF=""?dir=" & CurrentDir & "/" & BrowsedFolder.Name & """>" & BrowsedFolder.Name & "</A>"
Response.Write "</td><td align=""right"">"
Response.Write BrowsedFolder.Size \ 1024 & "kB</td>"
Response.Write "<td>Filmapp</td>"
Response.Write "<td>" & FormatDateTime(BrowsedFolder.DateCreated, 2) & " </td></tr>"
ContainsSomething = "True"
end if
next
for each BrowsedFile in BrowseContents.Files
FileExtBegPos = InStrRev(BrowsedFile.Name, ".")
FileExtTotal = len(BrowsedFile.Name)
FileExt = Right(BrowsedFile.Name, FileExtTotal - FileExtBegPos)
select case FileExt
case "asp"
FileIcon = "aspicon.gif"
case "htm", "html", "shtm", "shtml"
FileIcon = "htmlicon.gif"
case "jpg", "jpeg", "gif", "png", "bmp"
FileIcon = "imgicon.gif"
case "zip", "rar", "tar", "gz"
FileIcon = "zipicon.gif"
case "exe"
FileIcon = "exeicon.gif"
case "mp3", "wav", "rm", "wmv"
FileIcon = "mp3icon.gif"
case else
FileIcon = "icon.gif"
end select
Response.Write "<tr>"
Response.Write "<td><img src=""images/" & FileIcon & """> <A HREF=""" & CurrentDir & "/" & BrowsedFile.Name & """>" & BrowsedFile.Name & "</A>"
Response.Write "</td><td align=""right"">"
Response.Write BrowsedFile.Size \ 1024 & " kB</td>"
Response.Write "<td>" & BrowsedFile.type &"</td>"
Response.Write "<td>" & FormatDateTime(BrowsedFile.DateCreated, 2) & " </td></tr>"
ContainsSomething = "True"
next
Response.Write "</table>"
if ContainsSomething <> "True" then
Response.Write "<TABLE WIDTH=""100%""><TR><TD><br><br>Det finns inga filer i denna mapp.</TD></TR></TABLE>"
end if
%>
</td>
</tr>
</table>
</body>
</html>
<%
Set FSO = Nothing
Set BrowseContents = Nothing
end if
%>
264 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e