---
title: "nån slags mappbrowser"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/48322-nån-slags-mappbrowser"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "oskob"
published: "2002-07-21T16:37:23.000Z"
updated: "2002-07-21T19:59:31.000Z"
replies: 3
views: 228
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/48322-nån-slags-mappbrowser"
---

# nån slags mappbrowser

## #1 — oskob, 2002-07-21T16:37Z

Hej jag sitter och försöker göra ett script som visar bilder i mappat.
Typ:
till vänster visas mappinnehållet (alla filler och sånt) och så kan man klicka på andra mappar och leta runt lite.
Jag har kommit så långt som att jag kan komma in i en mapp men inte i en mapp i den mappen osv. 
Ni skulle antagligen kräkas om ni såg koden för den är väldigt stökig.
Fasst det skiter jag i utifallatt någon skulle vilja kolla på mitt dåliga exempel.

Så här gör man inte:

\<% 
ID = Request.Querystring("id") 

Mapp = Request.Querystring("fold")

If Mapp = "" Then
sMapPath = server.mapPath(".")
Else
sMapPath = server.mapPath(".") & "\\" & Mapp
End If

Dim fso, folder, subFolder,f
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set folder = fso.GetFolder(sMapPath)
%\>
\<html\>
\<head\>
\<STYLE\>
a		{color: #000; text-decoration: underline; font-weight: bold;}
a:link 		{color: #000; text-decoration: underline; font-weight: bold; }
A:visited 	{color: #000; text-decoration: underline; font-weight: bold; }
A:active  	{color: #ff0000; text-decoration: none; }
A:hover   	{color: #ff0000; text-decoration: underline;}
body		{ font-family: Verdana; font-size: 7.5pt; color: #000 }
td		{ font-family: Verdana; font-size: 7.5pt; color: #000 }
body		{ background: #FFF }
\</STYLE\>
\<title\>Oskar´s bildvisare\</title\>
\</head\>
\<body\>
\<b\>\<big\>Oskar´s bildvisare\</big\>\<br\>\<br\>\</b\>
\<% response.Write sMapPath %\>

\<table border="0" cellspacing="10"\>
\<td valign="top"\>
\<b\>
\<font face='Verdana' size=1\>
\<%
    
    For Each subFolder in folder.subFolders
        response.write "\<a href='default.asp?fold=" & subFolder.name & "'\>" & subFolder.name & "\</a\>\<br\>"
    Next

'------------------------------------------------------

    For Each f in folder.files
    
    If Mapp = "" Then
    URL = "default.asp?id=" & f.name
    Else
    URL = "default.asp?id=" & f.name & "&fold=" & Mapp
    End If

    If Right(f.name,3) = "jpg" Or Right(f.name,3) = "gif" Or Right(f.name,3) = "JPG" Or Right(f.name,3) = "GIF" Then

    If ID = f.name Then
        Response.Write "\<font color='#ff0000'\>»\</font\>"
    Else
        Response.Write "»"
    End If

        Response.Write "\<a href='" & URL & "'\>" & f.name & "\</a\>\<br\>"

    Else
    End If

    Next

%\>
\</font\>
\</b\>
\</td\>
\<td valign="top"\>
\<% 
If ID = "" Then

Else

If Mapp = "" Then
Response.Write "\<img src='" & ID & "'\>"
Else
Response.Write "\<img src='" & sMapPath & "/" & ID & "'\>"
End If

End If
%\>
\</td\>
\</table\>
\</body\>
\</html\>

Mobba mig inte för koden  x(

Permalänk: https://www.webforum.nu/p/48322

## #2 — solbulle, 2002-07-21T17:10Z

Mina ändringar kanske inte är så särskilt genomtänkta, men det kanske kan ge någon ide.

```
<% 
ID = Request.Querystring("id") 

Mapp = Request.Querystring("fold") 

If Mapp = "" Then 
sMapPath = server.mapPath(".")
strMapp = ""								'// Lagt in en till variabel
Else 
sMapPath = server.mapPath(".") & "\" & Mapp
strMapp = Mapp & "/"							'// Lagt in en till variabel
End If 

Dim fso, folder, subFolder,f 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set folder = fso.GetFolder(sMapPath) 
%> 
<html> 
<head> 
<STYLE> 
a {color: #000; text-decoration: underline; font-weight: bold;} 
a:link {color: #000; text-decoration: underline; font-weight: bold; } 
A:visited {color: #000; text-decoration: underline; font-weight: bold; } 
A:active {color: #ff0000; text-decoration: none; } 
A:hover {color: #ff0000; text-decoration: underline;} 
body { font-family: Verdana; font-size: 7.5pt; color: #000 } 
td { font-family: Verdana; font-size: 7.5pt; color: #000 } 
body { background: #FFF } 
</STYLE> 
<title>Oskar´s bildvisare</title> 
</head> 
<body> 
<b><big>Oskar´s bildvisare</big><br><br></b> 
<% response.Write sMapPath %> 

<table border="0" cellspacing="10"> 
<td valign="top"> 
<b> 
<font face='Verdana' size=1> 
<% 

For Each subFolder in folder.subFolders 
response.write "<a href='default.asp?fold=" & strMapp & subFolder.name & "'>" & subFolder.name & "</a><br>" '// Ändrat i länken.
Next 

'------------------------------------------------------ 

For Each f in folder.files 

If Mapp = "" Then 
URL = "default.asp?id=" & f.name 
Else 
URL = "default.asp?id=" & f.name & "&fold=" & Mapp 
End If 

If Right(f.name,3) = "jpg" Or Right(f.name,3) = "gif" Or Right(f.name,3) = "JPG" Or Right(f.name,3) = "GIF" Then 

If ID = f.name Then 
Response.Write "<font color='#ff0000'>»</font>" 
Else 
Response.Write "»" 
End If 

Response.Write "<a href='" & URL & "'>" & f.name & "</a><br>" 

Else 
End If 

Next 

%> 
</font> 
</b> 
</td> 
<td valign="top"> 
<% 
If ID = "" Then 

Else 

If Mapp = "" Then 
Response.Write "<img src='" & ID & "'>" 
Else 
Response.Write "<img src='" & Mapp & "/" & ID & "'>"  '// Fungerar det för dig att visa en bild om du har sMapPath här?
End If 

End If 
%> 
</td> 
</table> 
</body> 
</html>
```

Permalänk: https://www.webforum.nu/p/727793

## #3 — oskob, 2002-07-21T19:06Z

det löser inte mitt problem :/

Permalänk: https://www.webforum.nu/p/727845

## #4 — solbulle, 2002-07-21T19:59Z

På vilket sätt löser det inte ditt problem?
Det kan ju alltid vara trevligt med ett lite konstruktivt svar.

Permalänk: https://www.webforum.nu/p/727872

---

Tråden på webben: https://www.webforum.nu/amne/asp/48322-nån-slags-mappbrowser
