Forums
 This topic is locked 
             display all images from specified folder
 Posted 15 Oct 2002  19:56:15 
  1 
     has   voted 
  15 Oct 2002  19:56:15 nigel burkinshaw posted: 
 how would i display all images from specified folder on the server using asp and vbscript? i have pureasp upload from george petrov if this helpsReplies
 Replied 15 Oct 2002  22:44:13 
   15 Oct 2002  22:44:13 Ned Frankly replied: 
  This will display all images in a folder - The folder is an absolute server path (see the function call after the Function definition).  This one is setup to allow for a database update based on one of the images being clicked (if you click an image, the filename is updated into the database).  If you need this functionality, modify the href code within the function to call the appropriate update page.
Function ShowFileList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject"
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & "<a href=""updateimage.asp?whatever=" & request("whatever" & "&cmd=update&image=" & f1.name & """><img vspace=5 hspace=5 border=0 src=""../images/lib/"
 & "&cmd=update&image=" & f1.name & """><img vspace=5 hspace=5 border=0 src=""../images/lib/"
s = s & f1.name
s = s & """></a>"
Next
ShowFileList = s
End Function
strFileList = ShowFileList("/home/sites/www.mywebsite.com/web/images/lib")
response.write strFileList
Ned Frankly
  Function ShowFileList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject"

Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & "<a href=""updateimage.asp?whatever=" & request("whatever"
 & "&cmd=update&image=" & f1.name & """><img vspace=5 hspace=5 border=0 src=""../images/lib/"
 & "&cmd=update&image=" & f1.name & """><img vspace=5 hspace=5 border=0 src=""../images/lib/"s = s & f1.name
s = s & """></a>"
Next
ShowFileList = s
End Function
strFileList = ShowFileList("/home/sites/www.mywebsite.com/web/images/lib")
response.write strFileList
Ned Frankly
 Replied 22 Oct 2002  17:04:47 
   22 Oct 2002  17:04:47 Ken Blasdel replied: 
  Do you know a way to do this with data base information.
I have a database that I have changed the items in the field to a hard code file location of images (i.e. file\\g|\somedire\somedir\image001.tif file\\g|\somedir\somedir\image002.tif etc) Is their some way to take the data out of the database and have DW turn those entries into linked file location?
 
  I have a database that I have changed the items in the field to a hard code file location of images (i.e. file\\g|\somedire\somedir\image001.tif file\\g|\somedir\somedir\image002.tif etc) Is their some way to take the data out of the database and have DW turn those entries into linked file location?
 Replied 22 Oct 2002  17:22:57 
   22 Oct 2002  17:22:57 Ned Frankly replied: 
  DW won't do it for you, but you can certainly parse out the filename portion of the full path using the filesystem object (or with straight VBScript) and reconstruct it into a virtual path ie 
www.mywebsite.com/images/<%=FileName%>
I recommend you research the FileSystemObject to see what you can do. ASP 2.0 from WROX has a pretty good description and usage chapter on the subject. I believe parts of it are in the online reference with UD and DMX.
Ned Frankly
  www.mywebsite.com/images/<%=FileName%>
I recommend you research the FileSystemObject to see what you can do. ASP 2.0 from WROX has a pretty good description and usage chapter on the subject. I believe parts of it are in the online reference with UD and DMX.
Ned Frankly