Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    ASP Photo Album... aiuto su modifiche al codice

    ho appena scaricato ASP Photo Album e, provandolo, ho notato che il codice preleva automaticamente le foto dalla cartella in cui risiede la pagina. come posso fare a dirgli di prelevare le foto da un altro percorso, prendendolo dal database? cosa devo modificare?
    ho fatto alcune prove ma non ho ottenuto il risultato sperato...

    Codice PHP:
    <html>

    <
    head>
    <
    title>Gallery</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </
    head>

    <
    style type="text/css">
    .
    imgBorder{
        
    padding0px;
        
    padding-bottom:2px;
        
    padding-top:2px;
        
    border1px solid #666666; 
    }
    .
    imgInsideBorder{border1px solid #666666;}
    bodytd {
        
    font-familyArialHelveticasans-serif;
    }
    .
    totals{color:#666666}
    </style>

    <
    body>



    <%
    thumbsPerPage      8               ' Number of thumbnails to display on the page
    thumbsPerRow      = 4                ' 
    Number of thumbnails to display per row surprised
    thumbIdentifier 
    ".jpg"        ' The common string ending for all thumbnail images.

    You should not need to change any ASP code below hereGo to line and beyond to change HTML
    pgURL 
    Request.ServerVariables("SCRIPT_NAME"'the name of this page eg. album.asp
    pgName = Right(pgURL, len(tt) - InStrRev(tt, "/")) ' 
    The current page's name
    page = request.queryString("page") '
    This is the page you are onused for paging

    if page "" then page 1         'If no page # exists, set to 1
    img = Request.querystring("img")   '
    Large image to display if they clicked a thumbnail 
    if img "" then                   'If there is no image on URL, show the thumbnail page

    Determine which image to start end at based upon paging and thumbsPerPage
    first 
    = ((page-1) * thumbsPerPage)
    last = (page thumbsPerPage)-'We do minus 1 here since we are using an array... array starts at 0 vs 1

      ' 
    get the current folder location
        strPathInfo 
    Request.ServerVariables("SCRIPT_NAME")
        
    strPhysicalPath Server.MapPath(strPathInfo)
        
    set objFSO CreateObject("Scripting.FileSystemObject")
        
    set objFile objFSO.GetFile(strPhysicalPath)
        
    set objFolder objFile.ParentFolder
        set objFolderContents 
    objFolder.Files
        
      
    ' Count total number of thumbnails
       totalImages = 0
       For each objFileItem In objFolderContents
          if inStr(LCase(objFileItem.Name),thumbIdentifier) then
              totalImages = totalImages + 1
          end if
       next
       
    '
    Limit last to totalImages so array does not go out of range.
    if 
    last totalImages then last totalImages

    'Array starts at 0 vs. 1 so we need to offset this by 1 exception last image can't be than total # of iamges
    lastDisplay last 1
    if lastDisplay totalImages then lastDisplay totalImages
       
       
    ' Create an array to put all the images in so that we can do paging
       dim arrayOfThumbs()
       ReDim arrayOfThumbs(totalImages) 

       i = 0
    Populate the array with the images
     
    For each objFileItem In objFolderContents
                    
    ' only display the thumbnails - the images that have the ending defined in the thumbIdentifier variable at top of page 
                    if inStr(LCase(objFileItem.Name),thumbIdentifier) then
              '
    Isolate the image name so that we can create a link to the large versionThis strips off the ending e.g. -01.jpg
                        image 
    split(objFileItem.NamethumbIdentifier)
            
    ' Populate array 
                    arrayOfThumbs(i)= "<td nowrap valign='
    top' align='center'><div class='imgBorder'>[url='" & image(0) & ".jpg'][img]mini/" & image(0) & ".jpg[/img][/url]</div></td>" & vbCrLf
                                   
            i = i + 1
            end if
     next

    Create page links if more than 1 page is needed
    dim paging
    if (thumbsPerPage totalImagesthen
    ' Assing all the page numbers to the paging string because we are going to use on top and bottom of page
    paging = "Pagina: [b]"
      k = 1
      Do 
        paging = paging + "[url='" & pgName & "
    ?page=" & k & "']" & k & "[/url]" & vbCrLf
        k = k + 1
      loop until (k * thumbsPerPage) >= totalImages
      paging = paging + "[url='" & pgName & "
    ?page=" & k & "']" & k & "[/url][/b]"     'One more becase the logic cuts the last one off
    end 
    if
    %>


     <
    h1 align="center" style="font-family:Tahoma">Gallery</h1>  

     <
    table align="center" cellspacing="5">
      <
    tr>
     <%
     
    ' Loop through the array and display images
      for j =  first to last
        response.write(arrayOfThumbs(j))
        if (j+1) Mod thumbsPerRow = 0 then response.Write(vbCrLf & "</tr><tr>" & vbCrLf) '
    Create a new row based on thumbsPer row
      next
     
    %> 
      </
    tr>
     </
    table>

     <
    p align="center">
     <%=
    paging%> 
     </
    p>


    <% 
    end if %>

    </
    body>

    </
    html

  2. #2
    Probabilmente dopo aver aperto la connessione al db e fatto la query, basta modificare la riga 171 del file default.asp in questo modo:
    codice:
      	[img]public/<%=rs("nomecampo")%>[/img]
    Credo, ma bisognerebbe provare

  3. #3
    Moderatore di ASP e MS Server L'avatar di Roby_72
    Registrato dal
    Aug 2001
    Messaggi
    19,559
    Quello script mi sembra cicli tutti i file immagine contenuti in una cartella mentre dovrebbe ciclare i record di una tabella.
    Tutta la parte centrale dello script dovrebbe essere sostituita.

    Roby

  4. #4
    Originariamente inviato da Roby_72
    Quello script mi sembra cicli tutti i file immagine contenuti in una cartella mentre dovrebbe ciclare i record di una tabella.
    Tutta la parte centrale dello script dovrebbe essere sostituita.

    Roby
    si esatto. questo script preleva le immagini presenti all'interno della cartella dove risiete il file default.asp.

    quello che dici tu è di modificare questa parte?

    Codice PHP:
      ' get the current folder location 
        strPathInfo = Request.ServerVariables("SCRIPT_NAME") 
        strPhysicalPath = Server.MapPath(strPathInfo) 
        set objFSO = CreateObject("Scripting.FileSystemObject") 
        set objFile = objFSO.GetFile(strPhysicalPath) 
        set objFolder = objFile.ParentFolder 
        set objFolderContents = objFolder.Files 
    ma come faccio a dirgli di prelevare i record da una tabella del db?

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 © 2026 vBulletin Solutions, Inc. All rights reserved.