473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Displaying the images in the folder

Hi ,
I am creating a web page in ASP. I will place some images in the folder,
The images placed in the folder should be disaplayed. I am having the two button in the web page if I click next button then the next image should be dispalyed, If i click prev button then the prev image in the folder shd be displayed.The images are not static... its if today i hav 10 images afetr some time i amy hav 15 images....

Pls help me...

Thanks in advance
Nov 29 '07 #1
7 1962
Displaying the images in the folder
--------------------------------------------------------------------------------

Hi ,
I am creating a web page in ASP. I will place some images in the folder,
The images placed in the folder should be disaplayed. I am having the two button in the web page if I click next button then the next image should be dispalyed, If i click prev button then the prev image in the folder shd be displayed.The images are not static... its if today i hav 10 images afetr some time i amy hav 15 images....

Pls help me...

Thanks in advance
Nov 30 '07 #2
shweta123
692 Expert 512MB
Hi,

To display the images on web page , you can use FileSystemObject.

<%

Dim obj
Dim folder
Dim file

'''''Create FileSystemObject

Set obj = Server.CreateObject("Scripting.FileSystemObject")

'''''''Get the folder folder for your image path

Set folder = obj.GetFolder(folderpath)

'''''''Get each file in that folder

For Each file In folder.Files%>
<img src =<%= file.path%>>
<%Next%>

Displaying the images in the folder
--------------------------------------------------------------------------------

Hi ,
I am creating a web page in ASP. I will place some images in the folder,
The images placed in the folder should be disaplayed. I am having the two button in the web page if I click next button then the next image should be dispalyed, If i click prev button then the prev image in the folder shd be displayed.The images are not static... its if today i hav 10 images afetr some time i amy hav 15 images....

Pls help me...

Thanks in advance
Dec 3 '07 #3
Hi Swetha,

Thanks a lot for ur reply and help....
Its working fine....

It is displaying all the images in the same page......

Thanks a lot
Dec 5 '07 #4
Nicodemas
164 Expert 100+
It's a good solution, but he did say he wanted previous/next buttons.

this should work, though, i did not test it.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. '//----------------------------------------------------
  3. '// declare some constants and variables
  4. '//----------------------------------------------------
  5. dim oFileSystem, oFolder, nFile, i, aFilenames, lookUp
  6.  
  7. i = 0
  8. const IMAGE_DIRECTORY = "/path_to_my_image_directory/"
  9.  
  10. '//----------------------------------------------------
  11. '// set up FSO
  12. '//----------------------------------------------------
  13. set oFileSystem = server.createobject("scripting.filesystemobject")
  14.  
  15. '//----------------------------------------------------
  16. '// get all images in image directory, store filenames
  17. '// in array
  18. '//----------------------------------------------------
  19. set oFolder = oFileSystem.getFolder(server.mappath(IMAGE_DIRECTORY))
  20.  
  21. '//----------------------------------------------------
  22. '// resize array to fit number of files in directory
  23. '//----------------------------------------------------
  24. redim aFilenames(oFolder.files.count - 1)
  25.  
  26. '//----------------------------------------------------
  27. '// loop through files in folder, assign each to
  28. '// index in array
  29. '//----------------------------------------------------
  30. for each nFile in oFolder.files
  31.    aFilenames(i) = nFile.name
  32.    i = i + 1
  33. next
  34.  
  35. set oFolder = nothing
  36. set oFileSystem = nothing
  37.  
  38. '//----------------------------------------------------
  39. '//determine which image the user wants to look at
  40. '//----------------------------------------------------
  41. if request.querystring("pic") <> "" and isnumber(request.querystring("pic")) then
  42.    lookUp = cint(request.querystring("pic"))
  43.    '//----------------------------------------------------
  44.    '// make sure the value of lookUp doesn't break
  45.    '// our array bounds
  46.    '//----------------------------------------------------
  47.    if (lookUp < 0 or lookUp > ubound(aFilenames)) then 
  48.       lookUp = 0
  49.    end if
  50. else
  51.    lookUp = 0
  52. end if
  53. %>
  54.  
  55. <html>
  56. <body>
  57.    <img src="<%= IMAGE_DIRECTORY %><%= aFilenames(lookUp) %>" />
  58.    <br />
  59.    <a href="?pic=<%= lookUp - 1 %>"><< Previous</a> &nbsp; <a href="?pic=<%= lookUp + 1 %>">Next >></a>
  60.  
  61. </body>
  62. </html>
Dec 7 '07 #5
It's a good solution, but he did say he wanted previous/next buttons.

this should work, though, i did not test it.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. '//----------------------------------------------------
  3. '// declare some constants and variables
  4. '//----------------------------------------------------
  5. dim oFileSystem, oFolder, nFile, i, aFilenames, lookUp
  6.  
  7. i = 0
  8. const IMAGE_DIRECTORY = "/path_to_my_image_directory/"
  9.  
  10. '//----------------------------------------------------
  11. '// set up FSO
  12. '//----------------------------------------------------
  13. set oFileSystem = server.createobject("scripting.filesystemobject")
  14.  
  15. '//----------------------------------------------------
  16. '// get all images in image directory, store filenames
  17. '// in array
  18. '//----------------------------------------------------
  19. set oFolder = oFileSystem.getFolder(server.mappath(IMAGE_DIRECTORY))
  20.  
  21. '//----------------------------------------------------
  22. '// resize array to fit number of files in directory
  23. '//----------------------------------------------------
  24. redim aFilenames(oFolder.files.count - 1)
  25.  
  26. '//----------------------------------------------------
  27. '// loop through files in folder, assign each to
  28. '// index in array
  29. '//----------------------------------------------------
  30. for each nFile in oFolder.files
  31.    aFilenames(i) = nFile.name
  32.    i = i + 1
  33. next
  34.  
  35. set oFolder = nothing
  36. set oFileSystem = nothing
  37.  
  38. '//----------------------------------------------------
  39. '//determine which image the user wants to look at
  40. '//----------------------------------------------------
  41. if request.querystring("pic") <> "" and isnumber(request.querystring("pic")) then
  42.    lookUp = cint(request.querystring("pic"))
  43.    '//----------------------------------------------------
  44.    '// make sure the value of lookUp doesn't break
  45.    '// our array bounds
  46.    '//----------------------------------------------------
  47.    if (lookUp < 0 or lookUp > ubound(aFilenames)) then 
  48.       lookUp = 0
  49.    end if
  50. else
  51.    lookUp = 0
  52. end if
  53. %>
  54.  
  55. <html>
  56. <body>
  57.    <img src="<%= IMAGE_DIRECTORY %><%= aFilenames(lookUp) %>" />
  58.    <br />
  59.    <a href="?pic=<%= lookUp - 1 %>"><< Previous</a> &nbsp; <a href="?pic=<%= lookUp + 1 %>">Next >></a>
  60.  
  61. </body>
  62. </html>



Hi ,

Thanks a lot for ur timely help .. I will check it and let u know...

Thanks again
Dec 14 '07 #6
Hi ,
Its working well. Thanks a lot.
Dec 18 '07 #7
Nicodemas
164 Expert 100+
You're welcome :D I am happy it worked out for you.
Dec 18 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Mark Sargent | last post by:
Hi All, response.write FilePath gives this path, ImageName.jpeg but the image(s) doesn't display in the below code. What am I missing..? Cheers. <%Response.Write FilePath%> Original...
3
by: Michel | last post by:
Hi, This is my first post and I may be asking a question that's got a very simple explanation. I hope. I'm building a website and testing it goes fine on Netscape and Mozilla. Pixel perfect.
7
by: Vinay | last post by:
Hi All: I have a small application that stores images either in the database or as files (depending on the user preference). I'm in the process of providing a web interface to this application....
15
by: Jameson | last post by:
Happy New Year, Everyone! I am trying to figure out how to display a bunch of images (mainly JPEGs, but possibly a few GIFs and PNGs as well) that are stored in a local directory on the system....
8
by: Lloyd Sheen | last post by:
I have a list of JPG's which are found in a SQL Server database. When the page selects a certain piece of data it will refer to the file system (resident on IIS server with a virtual directory)...
5
by: kbnolan | last post by:
I'm somewhat new to this so I know there is something easy I'm missing. I'm editing an existing html page that was built with primarily with css. I have to work with the existing structure and not...
11
by: Marge | last post by:
After importing a VB6 project into Express 2008 I have two gif's with transparency do not display correctly. In VB6 these pictures where used with the image object which had different properties...
3
by: mvijayrkumar | last post by:
Hi to all.... Guys pls help me..... I have an image issue in RLDC while hosting my project on server.The image displays or works fine with the local system.But when hosted on server,both the...
5
by: Ca1icoJack | last post by:
I'm new to Javascript and want to write a script which will loop through the files in a folder and display them in a webpage. I've written the following which alternately displays two images in a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.