Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2006, 09:17 AM
Registered User
 
Join Date: Jun 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default display pictures from directory

Hi,
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?
Thanks

Janiv
 
Old June 12th, 2006, 05:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.
 
Old June 14th, 2006, 01:20 AM
Authorized User
 
Join Date: May 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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..

Code:
<% Option Explicit %>

<html>
<head>
<title>Untitled</title>
</head>

<body>

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

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

</form>

<%
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
        Next
    Else
        Response.Write("Folder " & strPath & " does not exist.")
    End If
    Set fso=nothing
    Set fsoFolder=nothing
End If
%>

</body>
</html>


Hasta Luego..
KingRoon

DogFightClothing. No dogs. No fighting.

http://www.dogfightclothing.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display pictures on JSP page? coitri JSP Basics 19 November 24th, 2008 06:22 AM
How to display pictures on JSP page? Kisat JSP Basics 1 November 3rd, 2008 09:02 PM
Display many pictures NBM Java GUI 0 September 3rd, 2006 06:54 AM
display pictures from directory chetrity Classic ASP Basics 1 June 15th, 2006 01:01 PM





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