Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 19

Discussione: come scelgo il path?

  1. #1
    Utente di HTML.it L'avatar di fanoste
    Registrato dal
    Oct 2005
    Messaggi
    271

    come scelgo il path?

    ciao a tutti.
    sto impazzendo.
    ho uno script (trovato in rete) che permette di visualizzare i photoalbum presenti nelle cartelle.
    Fin quando ho tenuto la pagina in una subdirectory nessun problema, mi visualizzava tutte le cartelle all'interno della sub ed ora ok.
    Ora devo spostare la pagina nella root, ma così facendo lo script visualizza tutte le cartelle all'interno della stessa.
    Cosa devo cambiare per fare in modo di visualizzare solo le cartelle presenti all'interno della subdirectory "foto" per esempio?

    grazie

    ecco il codice:

    [I]
    <%

    ' PhotoAlbum

    Dim CurFile, PopFileShowSub, ShowPic, PictureNo
    Dim strPathInfo, strPhysicalPath


    Dim intTotPics, intPicsPerRow, intPicsPerPage, intTotPages, intPage, strPicArray()
    intPicsPerRow = 4
    intPicsPerPage = 4

    intPage = CInt(Request.QueryString("Page"))
    If intPage = 0 Then
    intPage = 1
    End If


    CurFile = "PhotoAlbum.asp"
    PopFile = "ShowPicture.asp"
    %>

    <link rel="stylesheet" type="text/css" href="gallery/style.css">
    <script language="JavaScript">

    <!--
    function jumppage(sel)
    {
    var i = sel.selectedIndex
    self.location.href = sel.options.value
    }
    // -->
    </script>
    <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=820,height=600,s creenX='+xOffset+',screenY='+yOffset+',top='+yOffs et+',left='+xOffset+',scrollbars=auto,toolbars=no, menubar=no,resizable=yes')
    }
    // done hiding -->
    </script>
    <link href="pagina.css" rel="stylesheet" type="text/css">
    <title></title>
    <p align="center"></p>
    <p align="center"></p>
    <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="100%" id="AutoNumber1">
    <tr>

    <td align="center" width="25%">
    <form action=<%=PopFile%> method="POST">
    <font face="<%= strDefaultFontFace %>" size="<% =strFooterFontSize %>" color="<% =strBaseFontColor %>"><b class="occhiello">Seleziona la galleria:[/b]
    <select name="go" onChange="jumppage(this);" size=1>
    <%
    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
    Response.write "<option "
    If ShowSub=Folder.Name Then
    Response.Write "selected "
    End if
    Response.Write"value='" & CurFile & "?ShowSub="
    Response.Write(Replace(Folder.Name, " ", "%20"))
    response.write "'>"
    Response.Write(Folder.Name & "</option>")
    If ShowSub <= " " Then
    ShowSub = Folder.Name
    End if
    End if
    Next
    Set objFSO = Nothing
    %>
    </select></h3>
    </form>
    </td>
    </tr>
    </table>


    <%
    If ShowPic > " " then
    ShowPic = Replace(ShowPic, " ", "%20")
    Response.Write "<a href='JavaScript:history.go(-1)'>[img]" & ShowPic & "[/img]

    <font face=""verdana"" class=""notizie"" size=""1"">Indietro</a>"
    Else
    %>
    <table border="0" cellpadding="0" cellspacing="5" style="border-collapse: collapse" bordercolor="#000000" width="100%" id="AutoNumber1">
    <tr>
    <%
    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'>Pagina:"
    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 "" & x & ""
    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=""JavascriptpenGalleryWindow('" & PopFile & "?ShowPic=" & ShowSub & "/" & ShowPic & "')"""
    Response.write "
    "
    Response.Write("[img]" & ShowSub & "/" & strPicArray(0,x) & "[/img] ")
    Response.Write("
    <font color=""" & strBaseFontColor & """>" & Mid(strPicArray(0,x),1,Len(strPicArray(0,x))-4) & "</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
    %>




    </center>
    </html>

  2. #2
    prova a mettere al posto di questi due

    codice:
    strPathInfo = Request.ServerVariables("PATH_INFO")
    strPhysicalPath = Server.MapPath(strPathInfo)
    questo:
    codice:
    strPhysicalPath = Server.MapPath("/foto") 'se la cartella "foto" è una delle subdirectory della root

    ps: la prossima volta ci usi per favore i tag [ C O D E ] e [ / C O D E ] per delimitare il tuo codice?

  3. #3
    Utente di HTML.it L'avatar di fanoste
    Registrato dal
    Oct 2005
    Messaggi
    271
    grazie per la risposta ma non funziona.
    Ci avevo già provato... ma la combolist continua ad essere vuota!

  4. #4
    codice:
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.getFolder(strPhysicalPath)
    Set objFolderContents = objFolder.Files
    For each Folder in objFolder.SubFolders
    If Left(Folder.Name,1)<>"_" Then
    Response.write "<option "
    If ShowSub=Folder.Name Then
    Response.Write "selected "
    End if
    Response.Write"value='" & CurFile & "?ShowSub="
    Response.Write(Replace(Folder.Name, " ", "%20"))
    response.write "'>"
    Response.Write(Folder.Name & "</option>")
    If ShowSub <= " " Then
    ShowSub = Folder.Name
    End if
    End if
    Next 
    Set objFSO = Nothing
    sostituisci

  5. #5
    ciao ragazzi, anche io ho lo stesso problema, ho fatto le modifiche ma ora mi da questo errore:

    Microsoft VBScript runtime error '800a004c'
    Path not found

    /PhotoAlbum.asp, line 131

    codice linea 131: Set objFolder = objFSO.GetFolder(strPhysicalPath)

  6. #6
    fatti stampare la path e vedi se è giusta

  7. #7
    Utente di HTML.it L'avatar di fanoste
    Registrato dal
    Oct 2005
    Messaggi
    271
    adesso funge perfettamente!! grazie!!!

    un piccolo particolare che non c'entra nulla con asp :

    in quel form, come faccio a definire un carattere + piccolo nella combolist?

  8. #8
    Originariamente inviato da santino83
    fatti stampare la path e vedi se è giusta
    scusa ma come si fa?

  9. #9
    Originariamente inviato da fanoste
    adesso funge perfettamente!! grazie!!!

    un piccolo particolare che non c'entra nulla con asp :

    in quel form, come faccio a definire un carattere + piccolo nella combolist?
    passagli nella class un css adeguato (chiedi ai css-isti)



    X CLARA:
    codice:
    response.write strPhysicalPath
    response.end
    Set objFolder = objFSO.GetFolder(strPhysicalPath)
    controlla che quello che ti stampa sia un percorso valido

  10. #10
    X CLARA:
    codice:
    response.write strPhysicalPath
    response.end
    Set objFolder = objFSO.GetFolder(strPhysicalPath)
    controlla che quello che ti stampa sia un percorso valido
    niete da fare! il percorso è giusto, infatti vedo le caretelle ma non le foto in esse contenute

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.