Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to load images from folder

Status
Not open for further replies.

Dhagaxtuur

Technical User
Apr 15, 2003
47
CA
Is there a way to populate list box with all the images of folder?. I have folder called images, and I want all the contents to be displayed in listbox dynamically. These images are loaded to the folder so they can be any number of images at any time.
 
This should work for you, just change the MyFolderPath to your image folder path.
<%

'# Jason H
'# vzio.com
'# Aug 10, 2003 @ 2 am
Dim objFileScripting
Dim objFolder
Dim MyFolderPath

'# Your image folder path
MyFolderPath = &quot;c:\inetpub\
Set objFileScripting = CreateObject(&quot;Scripting.FileSystemObject&quot;) 'file scripting object
Set objFolder = objFileScripting.GetFolder(MyFolderPath)

Set filecollection = objFolder.Files


If NOT objFolder.Files.Count <= 0 Then
For Each filename In filecollection

strLoopCount = 0

Filename=right(Filename,len(Filename)-InStrRev(Filename, &quot;\&quot;)) %>
<tr>
<td><div align=&quot;center&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td><div align=&quot;center&quot;> </div>
<div align=&quot;center&quot;><select name=&quot;&quot;>
<option value=&quot;1&quot;><%=Filename%></option>
</select></div></td>
</tr>
</table>
</div></td>
</tr>
<%
strLoopCount = strLoopCount + 1
Next
Else ' No Images found
%>
<tr>
<td><div align=&quot;center&quot;><font size=&quot;2&quot; face=&quot;Verdana, Arial, Helvetica, sans-serif&quot;><strong>No
images found in folder.</strong></font></div></td>
</tr>
<% End If %>

www.vzio.com
ASP WEB DEVELOPMENT
 
I changed the folder path to my images forlder but I am getting this error:

Microsoft VBScript runtime error '800a004c'

Path not found

/try/try.asp, line 11

Do you know why?
 
the only thing I can think of why it cant find the path is maybe the backslash at the end... other then that it should work fine.

let me know.

- Jason

www.vzio.com
ASP WEB DEVELOPMENT



 
Thank very much SNOWBOARDR. With little modification, you help saved my day. Thnks.

<%

'# Jason H
'# vzio.com
'# Aug 10, 2003 @ 2 am
Dim objFileScripting
Dim objFolder
Dim MyFolderPath

'# Your image folder path
MyFolderPath = Server.MapPath(&quot;\cliktoprogram\try\images\&quot;)

Set objFileScripting = CreateObject(&quot;Scripting.FileSystemObject&quot;) 'file scripting object
Set objFolder = objFileScripting.GetFolder(MyFolderPath)

Set filecollection = objFolder.Files

%>

<select name=&quot;picture&quot;>
<%
If NOT objFolder.Files.Count <= 0 Then
For Each filename In filecollection

strLoopCount = 0

Filename=right(Filename,len(Filename)-InStrRev(Filename, &quot;\&quot;)) %>
<option value=&quot;1&quot;><%=Filename%></option>
<%
strLoopCount = strLoopCount + 1
Next
%>

</select>
<%
Else ' No Images found
%>
Not fournd
<% End If %>
 
no problem, think its worth a star?

www.vzio.com
ASP WEB DEVELOPMENT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top