Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Newbie Question: displaying images in a directory
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

seahorse
Senior Member

USA
1075 Posts

Posted - 27 March 2002 :  20:41:22  Show Profile  Visit seahorse's Homepage
Hi Everybody,

I was wondering if anyone knew of a technique using ASP where I could display images in a directory without having to resort to using a DB. I've got a setup using Access, but entering the thumbnail path, image path, thumbnail file name, and full size image name is taking forever. (I've got hundreds of images.)

What I'd like to do is use ASP to display thumbnail images and then allow the user to click through for a full sized version. Is this possible?

I know that I can link to images in a directory using the filesystem object, but does anyone know if I can use it for this problem?


Ken

===============
The greatest tragedy is a child without a loving parent.

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 27 March 2002 :  21:15:18  Show Profile
You should be able to. You could loop through all of the image files (.gif, .jpg, etc) and display names and/or the pictures themselves.

Nikkol
Go to Top of Page

seahorse
Senior Member

USA
1075 Posts

Posted - 28 March 2002 :  21:19:10  Show Profile  Visit seahorse's Homepage
quote:

You should be able to. You could loop through all of the image files (.gif, .jpg, etc) and display names and/or the pictures themselves.



Thanks. Any ideas on where I can start? I've been peeking through aspin.com for examples, but I haven't committed the time to really try and figure out how it works yet.

Ken

Ken

===============
The greatest tragedy is a child without a loving parent.
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 28 March 2002 :  21:57:57  Show Profile
Here's a snippet of code from microsoft to get you going

[VBScript]
Function ShowFolderList(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 & f1.name
s = s & "<BR>"
Next
ShowFolderList = s
End Function

read more here

Nikkol
Go to Top of Page

OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 28 March 2002 :  22:23:06  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
I've modified an old script I wrote, hope that helps:


<%
folder = "/"
If Left(server.mappath("."),1) = "/" Then
strslash = "/"
Else
strslash = "\"
End If
servername = Request.Servervariables("server_name")
scriptpath = Request.Servervariables("script_name")
scriptpath = Mid(scriptpath,(Instrrev(scriptpath, "/")),1)
Dim filesobj, fileslist, fname, posnumright
dim f, dflm
Set filesobj = Server.CreateObject("scripting.filesystemobject")
Set fileslist = filesobj.GetFolder(server.mappath(".") & "/" & folder)

For each thing In fileslist.files
posnumright = instrrev(thing, strslash)
fname = right(thing,(len(thing)-posnumright))
Set f = filesobj.GetFile(thing)
fdlm = f.datelastmodified
If f.size > 1023 Then
fsize = CStr(CInt(f.size / 1024)) & "k"
Else
fsize = CStr(f.size) & " bytes"
End If
image = Instr(".gif,.jpg", Right(fname,4)) > 0
physicalpath = server.mappath(".")
if image then %>
<a href="http://<%=servername & scriptpath & "upload/" & Server.HTMLEncode(fname) %>" title="<% =Server.HTMLEncode(fname) %>" target="_blank">
<img src="http://<%=servername & scriptpath & "upload/" & Server.HTMLEncode(fname) %>" title="<% =Server.HTMLEncode(fname) %>" border="0"></a><br><br>
<% end if
Set f = Nothing
Next
Set fileslist = Nothing
Set filesobj = Nothing
%>


Note that there's some stuff you might not need, the script gets the file size and last upadte info, and you have to correct the path and the link to your full images if you want to show thumbnails.

Feel free to ask if you need more help.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs


Edited by - OneWayMule on 28 March 2002 22:35:12
Go to Top of Page

OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 28 March 2002 :  22:32:56  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
Oh, and I've put up a little demo for you:

http://firewire.adsl.dk/onewaymule/seahorse/

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

seahorse
Senior Member

USA
1075 Posts

Posted - 29 March 2002 :  02:05:47  Show Profile  Visit seahorse's Homepage
Alright! Nikkol, OneWayMule, I love you both! Now to take a look and try to understand what's going on...hmmm...

No more entries into the DB. Woo Hoo!


Ken

===============
The greatest tragedy is a child without a loving parent.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.18 seconds. Powered By: Snitz Forums 2000 Version 3.4.07