Folder problemer ASP
Hej Eksperter,nedenstående script virker fint hos mig. Det lister alle folderne i den folder som filen ligger i. Jeg kunne så godt tænke mig at kunne angive en sti, så det ikke er nødvendigt at placere den i netop den folder som den skal vise alle folderne i.
<%
ShowSub = request("ShowSub")
ShowPic = request("ShowPic")
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
For each Folder in objFolder.SubFolders
If Left(Folder.Name,1)<>"_" Then
If ShowSub=Folder.Name Then
End if
'Response.Write"<br>"
Response.Write"<img src=grafik/bullet.gif>"
Response.Write"<a href=gallery.asp?ShowSub="
Response.Write(Replace(Folder.Name, " ", "%20"))
Response.Write"> "
Response.Write(Replace(Folder.Name, " ", "%20"))
Response.Write"</a>"
Response.Write"<br>"
If ShowSub <= " " Then
ShowSub = Folder.Name
End if
End if
Next
Set objFSO = Nothing
%>
Håber der er en venlig sjæl der lige hurtig kan tilføje det til koden.
Hele koden ser sådan ud, hvis det hjælper mere.
<%
Response.Expires=0 ' ----- virker med IE 4.0 browsers.
Response.AddHeader "Pragma","no-cache" ' ----- virker med proxy servers.
Response.AddHeader "cache-control", "no-store" ' ----- virker med IE 5.0 browsers.
session.lcid = 1030
%>
<!-- #include file="includes/dsn.asp" -->
<!-- #include file="includes/statistik.asp" -->
<!-- #include file="header.asp" -->
<script language="JavaScript">
<!-- hide from JavaScript-challenged browsers
function openGalleryWindow(url) {
if (document.all)
var xMax = screen.width, yMax = screen.height;
else
if (document.layers)
var xMax = window.outerWidth, yMax = window.outerHeight;
else
var xMax = 800, yMax=600;
var xOffset = (xMax - 200)/2, yOffset = (yMax - 200)/2;
var xOffset = 100, yOffset = 100;
popupWin = window.open(url,'new_page','width=700,height=535,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',scrollbars=auto,toolbars=no,menubar=no,resizable=yes')
}
// done hiding -->
</script>
<script language="JavaScript">
<!--
function jumppage(sel)
{
var i = sel.selectedIndex
self.location.href = sel.options[i].value
}
// -->
</script>
<%
' PhotoAlbum
Dim CurFile, PopFileShowSub, ShowPic, PictureNo
Dim strPathInfo, strPhysicalPath
Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages, intPage, strPicArray()
intPicsPerRow = 4
intPicsPerPage = 80
intPage = CInt(Request.QueryString("Page"))
If intPage = 0 Then
intPage = 1
End If
CurFile = "gallery.asp"
PopFile = "ShowPicture.asp"
%>
<% if pageid=1 then%>
<br>
<table width="644" height="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="ramme">
<tr>
<td width="366" align="left" valign="top" style="padding-left:8px;"><img src="grafik/slogan.gif" width="183" height="85"></td>
<td width="348" align="right" valign="top" style="padding-right:8px; "><img src="grafik/logo.gif" width="250" height="85"></td>
</tr>
<tr>
<td colspan="2" valign="top" style="padding:0px 1px 0px 1px;"><img src="grafik/pic.jpg" width="642" height="167"></td>
</tr>
<tr>
<td colspan="2" valign="top" style="padding:0px 1px 0px 1px;"><img src="grafik/line.gif" width="642" height="4"></td>
</tr>
<tr>
<td height="100%" colspan="2" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" bgcolor="#E0EAF3" style="border-right:1px solid #DDD; border-bottom:1px solid #DDD;"><img src="grafik/x" width="172" height="1"></td>
<td height="22" valign="top" style="border-bottom:1px solid #DDD; padding-left:15px;"><!-- #include file="menu.asp" --></td>
</tr>
<tr>
<td width="172" valign="top" style="border-right:1px solid #DDD;"><img src="grafik/forside.gif" width="65" height="9" style="margin:29px 0px 12px 15px; ">
<br>
<%
ShowSub = request("ShowSub")
ShowPic = request("ShowPic")
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
For each Folder in objFolder.SubFolders
If Left(Folder.Name,1)<>"_" Then
If ShowSub=Folder.Name Then
End if
'Response.Write"<br>"
Response.Write"<img src=grafik/bullet.gif>"
Response.Write"<a href=gallery.asp?ShowSub="
Response.Write(Replace(Folder.Name, " ", "%20"))
Response.Write"> "
Response.Write(Replace(Folder.Name, " ", "%20"))
Response.Write"</a>"
Response.Write"<br>"
If ShowSub <= " " Then
ShowSub = Folder.Name
End if
End if
Next
Set objFSO = Nothing
%>
</td>
<td valign="top"><table width="100%%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="29" valign="top"><img src="grafik/star.gif" width="29" height="7" style="margin-top:30px;"></td>
<td valign="top" style="padding:25px 20px 20px 0px;"><table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" bordercolor="#000000" width="100%" id="AutoNumber1">
<tr><%
' PhotoAlbum
'Dim CurFile, PopFileShowSub, ShowPic, PictureNo
'Dim strPathInfo, strPhysicalPath
'Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages, intPage, strPicArray()
intPicsPerRow = 4
intPicsPerPage = 80
intPage = CInt(Request.QueryString("Page"))
If intPage = 0 Then
intPage = 1
End If
CurFile = "gallery.asp"
PopFile = "ShowPicture.asp"
%>
<%
If ShowPic > " " then
ShowPic = Replace(ShowPic, " ", "%20")
Response.Write "<a href='java script:history.go(-1)'><img src='" & ShowPic & "'><BR><BR><font face=""verdana"" size=""1""><b>Go Back</b></a>"
Else
%>
<br>
<%
strPhysicalPath = Server.MapPath(".\" & ShowSub)
If ShowSub > " " then
ShowSub = Replace(ShowSub, " ", "%20")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strPhysicalPath)
Set objFolderContents = objFolder.Files
'Get the number of pictures in the subdirectory
intTotPics = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
intTotPics = intTotPics + 1
End if
Next
'Get the total number of pages in the subdirectory
If (intTotPics/intPicsPerPage) = (int(intTotPics/intPicsPerPage)) Then
intTotPages = int(intTotPics/intPicsPerPage)
Else
intTotPages = int(intTotPics/intPicsPerPage)+1
End If
Redim strPicArray(2,intTotPics)
'Store picture file names in an array
x = 0
For Each objFileItem in objFolderContents
If Ucase(Right(objFileItem.Name,4))=".GIF" OR Ucase(Right(objFileItem.Name,4))=".JPG" THEN
strPicArray(0,x) = objFileItem.Name
strPicArray(1,x) = Cstr(int(x/intPicsPerPage)+1)
x = x + 1
End if
Next
'Determine if there are multiple pages and if so, display page numbers.
If intTotPages > 1 Then
Response.Write "<td colspan='" & intPicsPerRow & "' align='center'><font face='Verdana,Arial' size='1'>Page: "
For x = 1 to intTotPages
If x = intPage Then
Response.Write "</font><font face='Arial' size='2'>" & x & "</font><font face='Arial' size='1'> "
Else
Response.Write "<a href='PhotoAlbum.asp?Page=" & x & "&ShowSub=" & ShowSub & "'>" & x & "</a> "
End If
Next
Response.Write "</font></td>"
Response.Write "</tr><tr><td> </td></tr><tr>"
End If
For x = 0 to UBound(strPicArray,2)-1
If CInt(strPicArray(1,x)) = intPage Then
ShowPic = Replace(strPicArray(0,x), " ", "%20")
Response.write "<td align='center' width='25%'><a href=""java script:openGalleryWindow('" & PopFile & "?ShowPic=" & ShowSub & "/" & ShowPic & "')"""
Response.write "<br>"
Response.Write("<img src='" & ShowSub & "/" & strPicArray(0,x) & "' width=50> ")
Response.Write("<br><font color=""" & strBaseFontColor & """><b>" & Mid(strPicArray(0,x),1,Len(strPicArray(0,x))-4) & "</b></font>")
Response.write "</a></td>" & vbcrlf
PictureNo = PictureNo + 1
If PictureNo=intPicsPerRow Then
Response.write "</tr><tr>"
PictureNo = 0
End if
End If
Next
Set objFSO = Nothing
End if
%>
</tr>
</table>
<%
End if
%> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<img src="grafik/x" width="1" height="7"><table width="644" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="color:#FFFFFF;">Skjern Skilte - Vendersgade 4 - 6900 Skjern - TLF. 97 35 22 44 - Fax. 97 35 02 72</td>
</tr>
</table>
<p><img src="x" width="1" height="5">
<%else%>
<br>
</p>
<table width="644" height="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="ramme">
<tr>
<td width="366" align="left" valign="top" style="padding-left:8px;"><img src="grafik/slogan.gif" width="183" height="85"></td>
<td width="348" align="right" valign="top" style="padding-right:8px; "><img src="grafik/logo.gif" width="250" height="85"></td>
</tr>
<tr>
<td colspan="2" valign="top" style="padding:0px 1px 0px 1px;"><img src="grafik/pic.jpg" width="642" height="167"></td>
</tr>
<tr>
<td colspan="2" valign="top" style="padding:0px 1px 0px 1px;"><img src="grafik/line.gif" width="642" height="4"></td>
</tr>
<tr>
<td height="100%" colspan="2" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" bgcolor="#E0EAF3" style="border-right:1px solid #DDD; border-bottom:1px solid #DDD;"><img src="grafik/x" width="172" height="1"></td>
<td height="22" valign="top" style="border-bottom:1px solid #DDD; padding-left:15px;"><!-- #include file="menu.asp" --></td>
</tr>
<tr>
<td width="172" valign="top" style="border-right:1px solid #DDD;"><img src="grafik/forside.gif" width="65" height="9" style="margin:29px 0px 22px 15px; "><br>
<img src="grafik/bullet.gif" width="43" height="8">Neonskilte<br></td>
<td valign="top"><table width="100%%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="29" valign="top"><img src="grafik/star.gif" width="29" height="7" style="margin-top:30px;"></td>
<td valign="top" style="padding:25px 20px 20px 0px;"><!-- #include file="afsnit/afsnit1.asp" --></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table><img src="grafik/x" width="1" height="7"><table width="644" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="color:#FFFFFF;">Skjern Skilte - Vendersgade 4 - 6900 Skjern - TLF. 97 35 22 44 - Fax. 97 35 02 72</td>
</tr>
</table>
<p><img src="x" width="1" height="5">
<%end if%>
</p>
</body>
</html>