så skal du vise mig lidt kode... bare smid hele foto.asp (hvis ikke den er sindsygt lang)
Synes godt om
Slettet bruger
14. august 2005 - 20:17#4
<% ImageDir = "/billeder/sjove/billeder/" 'This is the directory where the pictures are stored *CHANGE THIS* ' Remember to put the slash / in the end of these 2 variables CopyDir = "/billeder/sjove/billeder/" ' Same directory again. Don't ask Why :-) *CHANGE THIS* picturesperpage = 28 ' *CHANGE THIS TO THE AMOUNT OF PICTURES YOU WANT FOR EACH PAGE*
' ******************************************************* ' Check if we have a subdirectory in the parameter list. ' ******************************************************* subdir = REQUEST("subdir") IF REQUEST("subdir") <> "" THEN ImageDir = ImageDir & subdir & "/" ' Add the subdir in parameter to the current dir. end if directpath = server.mappath("/") & ImageDir ' Find the absolute path to the pictures %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <HTML> <HEAD>
<body> <div> <% ' ****************************************************************** ' This function is checking if AspImage is installed or not. ' ****************************************************************** Function IsComponentInstalled(ProgId) Dim tmpObject
On Error Resume Next
Set tmpObject = Server.CreateObject(ProgId) If Err.Number = 0 Then IsComponentInstalled = True Else IsComponentInstalled = False End If Set tmpObject = Nothing End Function
' ****************************************************************** ' Get picture, page and id, if they are passed as parameter ' ****************************************************************** picture = request("picture") id = request("id") pagenumber = request("page") If isNumeric(pagenumber) = False Or pagenumber < 1 Then pagenumber = 1 End If
'********************************************************************* '* Find all pictures in dictory '********************************************************************* Set objFS = CreateObject("Scripting.FileSystemObject") Set objFolder = objFS.GetFolder(Server.MapPath(ImageDir)) Set objFiles = objFolder.Files
numberofpictures = objFiles.Count strScriptName = Request.Servervariables("ScriptName") IF numberofpictures > 0 then intPageCount = -Int(-(numberofpictures/picturesperpage)) ELSE intPageCount = 1 END IF
IF picture="" then Response.Write "Total " & numberofpictures & " billeder i dette billede galleri." Response.Write " Dette er side " & pagenumber & " ud af " & intPageCount & "<BR><BR>" END IF
'******************************************************************** '* Write "Prev. Page" if currentpage is not page 1 '******************************************************************** If pagenumber > 1 Then newpage = pagenumber - 1 PgLink = "<a href='" & strScriptName & "?page=" & newpage IF subdir <> "" then PgLink = PgLink + "&subdir=" & subdir END IF PgLink = PgLink + "' class='sider'>[Prev. page] </A>" Response.Write PgLink End If
'********************************************************************* '* Do a link to all single pages '********************************************************************* For i = 1 To intPageCount PgLink = " <a href='" & strScriptName & "?page=" & i IF subdir <> "" then PgLink = PgLink + "&subdir=" & subdir END IF PgLink = PgLink + "' class='sider'>" & i & "</A>" Response.Write PgLink Next
'********************************************************************* '* Write "Next Page" if currentpage is not the last page '********************************************************************* If Cint(pagenumber) < Cint(intPageCount) then newpage = pagenumber + 1 PgLink = "<a href='" & strScriptName & "?page=" & newpage IF subdir <> "" then PgLink = PgLink + "&subdir=" & subdir END IF PgLink = PgLink + "' class='sider'> [Next page]</A>" Response.Write PgLink End If DIM picturearray
' ****************************************************************** ' Run through all files in the directory and put them in the list ' ****************************************************************** For Each Image In objFiles intFile = intFile + 1 picturelist = picturelist & Image.Name & "," Next
picturearray = Split(picturelist,",")
' **************************************************************************************** ' All places where testing on picture="" then it's because we have to show the thumbnails ' **************************************************************************************** IF picture="" then response.write "<BR>"
' **************************************************************************************** ' Check if there are any sub-directories in the current folder. If any are found, ' then show a link for them. ' ' First, if we already are in a subfolder, the do a link for the prev. folder- ' I'm doing a lot "not easy to read" string manipulation here. I don't want to use space ' to explain what i actually do in here. ' ****************************************************************************************
IF subdir <> "" THEN chkstr = "/" manipstr = left(ImageDir, Len(ImageDir)-1) NewDir=left(manipstr,InStrRev(manipstr, chkstr)) IF NewDir = CopyDir then ' This is because the prev. dir is the root. response.write " <A href='foto.asp'><IMG src='prdir.gif' alt='Root directory'></A> " ELSE NewDir = Mid(NewDir, Len(CopyDir)+1, Len(NewDir)-Len(CopyDir)-1) Response.write " <A href='foto.asp?subdir="&NewDir&"'><IMG src='prdir.gif' alt='"&NewDir&"'></A> " END IF END IF
Set fso = CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(directpath) Set subFolders = folder.SubFolders
For Each folderObject in SubFolders if subdir <> "" then thesubfolder = subdir & "/" & folderObject.Name else thesubfolder = folderObject.Name end if Response.Write " <A href='foto.asp?subdir="&thesubfolder&"'><IMG src='dir.gif' alt='"&folderObject.Name & "'></A> " Next Set subFolders = Nothing Set folder = Nothing Set fso = Nothing
FOR countit=0 TO intFile-1 If (countit >= (pagenumber-1)*picturesperpage) And (countit < (picturesperpage*pagenumber)) Then If IsComponentInstalled("AspImage.Image") Then PicLink = "<A href='"&strScriptName&"?picture="&picturearray(countit)&"&id="&countit IF subdir <> "" then PicLink = PicLink + "&subdir=" & subdir END IF PicLink = PicLink + "'><IMG SRC='crttmb.asp?path="&directpath & "&File="&picturearray(countit)&"' alt='Click here to view large picture.'></A> " response.write PicLink else PicLink = "<A href='foto.asp?picture="&picturearray(countit)&"&id="&countit IF subdir <> "" then PicLink = PicLink + "&subdir=" & subdir END IF PicLink = PicLink + "'><IMG SRC='"&ImageDir&picturearray(countit)&"' width='100' height='100' alt='Click here to view large picture.'></A> " response.write PicLink end if end if next END IF
' **************************************************************************************** ' Setup variables for next and previous pictures. Test if current picture is the first or ' **************************************************************************************** last IF picture<>"" then if cint(id)=0 then prev=numberofpictures-1 else prev=id-1 end if if cint(id)=cint(numberofpictures-1) then nextone=0 else nextone=id+1 end if
' ******************************************** ' Write the link to the previous picture ' ******************************************** PicLink = "<br><br><A href='"&strScriptName&"?picture="&picturearray(prev)&"&id="&prev IF subdir <> "" then PicLink = PicLink + "&subdir=" & subdir END IF PicLink = PicLink + "'>Prev. Picture</A> " response.write PicLink
' ******************************************** ' Write the link to the next picture ' ******************************************** PicLink = "<A href='"&strScriptName&"?picture="&picturearray(nextone)&"&id="&nextone IF subdir <> "" then PicLink = PicLink + "&subdir=" & subdir END IF PicLink = PicLink + "'>Next Picture</A> " response.write PicLink
If IsComponentInstalled("AspImage.Image") Then ' Set AspImage object to load width and height of the picture (used with the popup) Set Image = Server.CreateObject("AspImage.Image") Image.LoadImage directpath & picture thewidth= Image.MaxX theheight = Image.MaxY Set objImg = Nothing else thewidth = 1024 theheight = 768 end if
vaerd = """java script:openwindow('"&picture&"',"&thewidth& ","&theheight &")""" response.write "<BR><BR><A href="&vaerd&"><IMG src=""" & ImageDir & picture & """ width=""70%"" alt=""Click to open popup windows with original size picture.""></A>" end if
-------------- For Each folderObject in SubFolders if subdir <> "" then thesubfolder = subdir & "/" & folderObject.Name else thesubfolder = folderObject.Name end if Response.Write " <A href='foto.asp?subdir="&thesubfolder&"'><IMG src='dir.gif' alt='"&folderObject.Name & "'></A> " Next Set subFolders = Nothing Set folder = Nothing Set fso = Nothing -------------
til den her stump:
---------------- For Each folderObject in SubFolders if subdir <> "" then thesubfolder = subdir & "/" & folderObject.Name else thesubfolder = folderObject.Name end if Response.Write " <A href='foto.asp?subdir="&thesubfolder&"'><IMG src='dir.gif' alt='" & folderObject.Name & "'><br>" & folderObject.Name & "</A> " Next Set subFolders = Nothing Set folder = Nothing Set fso = Nothing --------------------------
Det der viser navnet er folderObject.Name. Den stod før kun i ALT-tagget på billedet (dir.gif). Nu står den også under billedet
Synes godt om
Slettet bruger
15. august 2005 - 17:31#6
er det muligt at man os kan få navnet til at stå under mappen ?
Nå !! Andre der har et svar på hvordan mappe navnet kommer til at ligge UNDER mappen ?
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.