VB icon

Picture browser(FSO)

Email
Submitted on: 1/6/2015 1:43:00 PM
By: Michael Seltenreich (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: VbScript (browser/client side)
Views: 702
 
     The code Desplays a list of images in a selected folder on the clients computer and lets him browse it. it is not very needed but is a gooood exemple of using fso. one of the thing i tell me studets is to try and make it a txt viewer instead of a image viewer, try it!
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Picture browser(FSO)
' Description:The code Desplays a list of images in a selected folder on the clients computer and lets him browse it. 
it is not very needed but is a gooood exemple of using fso. one of the thing i tell me studets is to try and make it a txt viewer instead of a image viewer, try it!
' By: Michael Seltenreich (from psc cd)
'
' Assumes:in order to run the code u must have a FSO activeX object
'**************************************

<script language="VBScript">
'Sets the Varibles
Dim filesys, demofolder, fil, filecoll, filist, filea,FPath,a
'Creats the FSO object
Set filesys = CreateObject("Scripting.FileSystemObject") 
'Pops a box asking for the location of the folder, and keeps it in the varible "a"
a=inputbox("Choose a folder u want to browse.")
FPath=a
'calls the folder the user asked for
Set demofolder = filesys.GetFolder(FPath) 
'calls the files in the above folder
Set filecoll = demofolder.Files
'a subroutine that gets a value.
sub ShowPic(path)
'desplays the image accepted in the sub's var in the main screen
viewer.innerHTML="<img alt=" & path & " src='" & a & "\" & path & "'><br>" & path 
'ends the sub
end sub 
'Creats the basic scenerio for the code
document.write "<table><tr><td><div style=height:600;overflow:scroll><table border=2>"
'runs a loop for each file in the folder
For Each fil in filecoll
'....
filea=filesys.GetExtensionName(fil.name)
	'Checks if the file has an image extension
	if filea="jpg" or filea="gif" or filea="bmp" then
	'if the file is in image he is added to the list of images
 filist = filist & "<tr><td><img alt=" & fil.name & " width=200 height=200 src='" & a & "\" & fil.name & "' onclick=ShowPic('" & fil.name & "')></td></tr>"
 end if 
Next 
'the full list of images is desplayed 
document.write (filist)
'Finals the code and creats the main screen
document.write "</table></div></td><td bgcolor=blue width=100% align=center valign=center><div name=viewer id=viewer></div></td></tr></table>"
</script>


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.