tim
|
Posted: 08/30/2002, 6:32 AM |
|
Hello all, I need to populate a listbox with the files located in a specific folder. A good example where this could be helpful is on the gotocode site on the myspace section diplaying your list of files.
what am i trying to do?
I have a form that people fill out and one field is for an image file. All their images are located in a images directory so I want a dropdoown listing these files so they can select it. On the back end to make it work I will add the http://www.sitename.com/images/ before the selected name (i hope). Any ideas?
|
|
|
tim
|
Posted: 08/30/2002, 8:03 AM |
|
here is what I am working with. This is very basic and just lists the files
<form>
<% @LANGUAGE="VBScript" %>
<%
'Reference the FileSystemObject
set FSO = Server.CreateObject("Scripting.FileSystemObject")
'Reference the Text directory
set Folder = FSO.GetFolder("C:\winnt")
'Reference the File collection of the Text directory
set FileCollection = Folder.Files
'Display the number of files within the Text directory
Response.Write("Number of files found: " & FileCollection.Count & "<BR>")
'Traverse through the FileCollection using the FOR EACH...NEXT loop
For Each FileName in FileCollection
strFileName = FileName.Name
Response.Write(strFileName & "<BR>")
Next
'De-reference all the objects
set FileCollection = Nothing
set Folder = Nothing
set FSO = Nothing
%>
</form>
|
|
|
tim
|
Posted: 09/03/2002, 5:41 AM |
|
I figured it out. Here is the solution if anyone can use it.
<form>
<% @LANGUAGE="VBScript" %>
<%
'Reference the FileSystemObject
set FSO = Server.CreateObject("Scripting.FileSystemObject")
'Reference the Text directory
set Folder = FSO.GetFolder("C:\winnt")
'Reference the File collection of the Text directory
set FileCollection = Folder.Files
'Display the number of files within the Text directory
Response.Write("Number of files found: " & FileCollection.Count & "<BR>")
%>
<SELECT id=cboFiles name=cboFiles>
<%
'Traverse through the FileCollection using the FOR EACH...NEXT loop
For Each FileName in FileCollection
strFileName = FileName.Name
%>
<OPTION value=<%=strFileName%>><%=strFileName%>
<%
Next
%>
</SELECT>
<%
'De-reference all the objects
set FileCollection = Nothing
set Folder = Nothing
set FSO = Nothing
%>
</form>
|
|
|
Pr3mium
|
Posted: 09/05/2003, 1:13 AM |
|
OK, code is working fine, but how should I use it in CCS? If I make an ASP file with this code, it works, but CCS uses HTML and ASP code separately. Any suggestions on how could I configure the listbox in CCS to list file names in the specified directory?
|
|
|