Jump to content
Fórum Script Brasil
  • 0

Galeria De Fotos Que Busca Nas Pasta


Guest --Maria Cláudia --
 Share

Question

Guest --Maria Cláudia --

Oi pessoal mais uma vez aqu para dá trabalho a vocês,

desta vez é o seguinte:

OBS.:> LEMBRO QUE SOU MUITO INICIANTE EM ASP

1. Ele mostra na barra de endereço quando clicamos na pasta para ver as fotos o enedereço fisico do path do servidor.

Ex.:

http://www.meusite.org.br/teste/index.asp?...ges\travel

e que queria que mostrasse assim:

http://www.meusite.org.br/teste/index.asp?...ges\travel

2. Na foto quando ele mostra na página ela está aparecendo com a extenção

ex.:

FOTO

arquivo1.jpg

eu queria que mostrasse assim:

FOTO

arquivo1

===========================

abaixo o códifgo index.asp

<!--#include file="config.inc"-->
<style>
BODY
{
    BACKGROUND-COLOR: white;
}
a
{
    color:blue;text-decoration:none;
}

a:hover
{
    color:red;text-decoration:underline;
}

td
{
    font-size:15px;
}
.header
{
    font-size:<%=headFontSize%>px;
}
</style>
<%

'decleration
dim folderName 'Folder Name
dim fso ' File System Object
dim fldr ' folder object
dim objFile
dim lastFolder
dim pathToFile
dim f 'file Object
dim i,o,p 'counters
dim buildFolders 
dim imageUrl
dim sf 'sub Folders
dim f1 'files in sub folder
dim vpath ' virtual path
dim result
dim blnImages
dim imgFolderFlag
dim x
'-----------------------------------------



'the folder name from queryString
folderName = request.queryString("folderName")


'security
blnImages = split(folderName,"\")




if folderName <> "" then
    for x = 0 to ubound(blnImages)
        if blnImages(x) = "images" then
            imgFolderFlag = true
            exit for
        end if
    next
    if imgFolderFlag <> true then
        response.write "<center>You are not authorized to view the files</center>"
        response.end
    end if
end if


if folderName="" then
    call getFilesByFolder(basePath,"images")
else
    call getFilesByFolder(folderName,"")
end if



sub getFilesByFolder(Bpath,folderName)
    'file System Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldr = fso.GetFolder(Bpath & folderName)
    response.write "<table align=center width='80%' border=0><tr>"
    i=0
    'loop over files
    For Each objFile in fldr.Files
        'split to get file name
        objFile = split(objFile,"\")
        lastFolder = ubound(objFile)
        
        'file size
        pathToFile = Bpath & folderName & "\" & objFile(lastFolder)
        Set f = fso.GetFile(pathToFile)
        
        'arrange pictures in a table
        
        if objFile(lastFolder) = "header.txt" then
            response.write "<div align=center>Folder <b>"& objFile(lastFolder-1) & "</b> description:</b><br>" & readTextFile(Bpath & folderName & "\header.txt") & "<br></div>"

        else
        response.write "<td align=center>"
        if objFile(lastFolder)<> "folder.gif" then
            'counter for pictures
            i = i + 1
            
            vpath = split(Bpath,"\")
            
            'converting to virtual path to display image
            for o = 0 to ubound(vpath)
                if vpath(o) = "images" then
                    exit for
                end if
            next
            
            for p = o+1 to ubound(vpath)
                buildFolders = buildFolders & vpath(p) & "/"
            next
            imageUrl = Bvpath & buildFolders
            response.write "<a href='" & imageUrl & objFile(lastFolder) & "' target='_blank'><img src='" & imageUrl & objFile(lastFolder) & "' width="&widthImage & " height="& heightImage & " border=0><br>" & "<a href='" & imageUrl & objFile(lastFolder) & "'>" & objFile(lastFolder)
        if f.name<>"folder.gif" then
            response.write "<b></a> (" & mid(f.size,1,2) & "K" & ")</b>"
        end if
        
        response.write "</td>"
        end if
        end if
        buildFolders = ""
        '3 pictures in <tr>
        result = i mod howManyPicsInRow
        if i > howManyPicsInRow-1 and result=0 then
            response.write "</td></tr>"
        end if
    next
    if i<>"" or i<>0 then
        response.write "</table><center><b>"& i & "</b> files were found<br><br><br></center>"
    else
        response.write "</table><center><b>No files were found<br><br><br><a href='#' onclick=history.go(-1)>back</a></center>"
    end if
    response.write "<table align=center width='80%' border=0><tr><td>"
    response.write "<tr><td><b>Browse Folders:</b></td></tr><tr><td>"
    'sub folders
    Set sf = fldr.SubFolders
      For Each f1 in sf
        response.write"<img src=images/folder.gif> " & "<a href='index.asp?folderName="& f1.path  &"'>" & f1.name & "</a><br>"
      Next
    response.write "<br><a href='#' onclick=history.go(-1)>back</a>"
      response.write "</td></tr></table>"
end sub

%>
=================== AQUI o config.inc
<%
'myImages - Elad Rosenberg March 2001
'-------------------------------------
'asp photo album
'-------------------------------------
'see the readme.txt before using
'-------------------------------------


option explicit
dim ForReading
dim objFSO
dim objNewFile
dim pathToTxt
dim MyString
dim basePath
dim Bvpath
dim howManyPicsInRow
dim widthImage
dim heightImage
dim headFontSize 


'---------- configuration (see the readme for more details) --------

basePath = "c:\domains\meusite.org.br\wwwroot\teste\"
Bvpath = "http://www.meusite.org.br/teste/images/"

'how many images per row
howManyPicsInRow = 2
'small pictures sizes
widthImage = 400
heightImage = 250
'header font size
headFontSize = 18

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






'read the header file function
function readTextFile(pathToTxt)
    'set file - for reading
    ForReading=1
    set objFSO = server.createobject("scripting.FileSystemobject")
    'open the text file
    set objNewFile = objFSO.OpenTextFile(pathToTxt, ForReading)
    'loop over the file until the end
    do while not objNewFile.AtEndOfStream
    'read line
    MyString = MyString & objNewFile.ReadLine & "<br>"
    loop
    readTextFile = MyString
End function

%>

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.8k
    • Total Posts
      646.6k
×
×
  • Create New...