• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

ASP Display folder contents

How do I adjust the code below to display in two columns?
<%
Dim oFilesys, oFolder, oFile
Set oFilesys= CreateObject("Scripting.FileSystemObject")
Set oFolder= oFilesys.GetFolder(Server.MapPath("/gallery/"))
For Each oFile in oFolder.Files
Response.write  "<img src=""/gallery/" & oFile.Name & """ width=""300"" />"
Response.write "<br />"
Next
 
Set oFolder=Nothing
Set oFilesys=Nothing
%>

Open in new window

0
wellsuited
Asked:
wellsuited
  • 2
1 Solution
 
DanielWillmottCommented:
Try this:
<%
Dim oFilesys, oFolder, oFile, x
Set oFilesys= CreateObject("Scripting.FileSystemObject")
Set oFolder= oFilesys.GetFolder(Server.MapPath("/gallery/"))
 
x=0
response.write "<table>"
 
For Each oFile in oFolder.Files
if x=0 then
     response.write "<tr>"
end if
response.write "<td>"
Response.write  "<img src=""/gallery/" & oFile.Name & """ width=""300"" />"
Response.write "</td>"
 
if x=1 then
     response.write "</tr>"
end if
x=1-x
Next
if x=1 then
     response.write "</tr>"
end if 
 
response.write "</table>"
 
Set oFolder=Nothing
Set oFilesys=Nothing
%>

Open in new window

0
 
DanielWillmottCommented:
Actually..change line 13 to:
response.write "<td style='width:300px'>"

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now