p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Components (http://p2p.wrox.com/forumdisplay.php?f=68)
-   -   display pictures from directory (http://p2p.wrox.com/showthread.php?t=43814)

chetrity June 11th, 2006 09:17 AM

display pictures from directory
I want to create asp form.
the input would be path of directory
the output would be table containing all the gif's in the directory

any idea how to do that? resource?


Greg Griffiths June 12th, 2006 05:51 PM

your best bet is to use the File Scripting Object (FSO) to process the directory in question and then have the ASP display all the images, and only images, found there in in a HTML output either using a table or some CSS DIV type display.

kingroon June 14th, 2006 01:20 AM

Hi Chetrity,

I guess the first problem is that using the <input type="file"> you have to select an actual file rather than a direcrory..

Try this..


<% Option Explicit %>



<form action="<%= Request.ServerVariables("SCRIPT_NAME") %>" method="post">

<input type="text" name="directory" value="C:\WINDOWS\system32"/> <input type="submit">


Dim strPath, fso, fsoFolder, fsoFile, i
If Request.Form("directory") <> "" Then
    strPath = Request.Form("directory")
    If Not Right(strPath, 1) = "\" Then
        strPath = strPath & "\"
    End If
    Set fso = Server.CreateObject("Scripting.FileSystemObject")
    If fso.FolderExists(strPath) = True Then
        Set fsoFolder = fso.GetFolder(strPath)
        Response.Write("Folder " & strPath & " exists.<br><br>")
        i = 1
        For Each fsoFile In fsoFolder.Files
            If UCase(fso.GetExtensionName(fsoFile.Name)) = "JPG" Or _
                UCase(fso.GetExtensionName(fsoFile.Name)) = "GIF" Or _
                UCase(fso.GetExtensionName(fsoFile.Name)) = "BMP" Or _
                UCase(fso.GetExtensionName(fsoFile.Name)) = "PNG" Then
                i = i + 1
                Response.Write "<img src=""" & strPath & fsoFile.Name & """ height=""80"" border=""0"" alt=""" & fsoFile.Name & """>"
                If i = 10 Then Response.Write "<br>"
                ' Or if you wanted to display simply each image name, uncomment this next line
                'Response.Write fsoFile.Name & "<br>"
            End If
        Response.Write("Folder " & strPath & " does not exist.")
    End If
    Set fso=nothing
    Set fsoFolder=nothing
End If


Hasta Luego..

DogFightClothing. No dogs. No fighting.


All times are GMT -4. The time now is 01:54 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.