Welcome to Dream.In.Code
Getting Help is Easy!

Join 118,658 Programmers for FREE! Ask your question and get quick answers from experts. There are 889 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Addition on root files

 
Reply to this topicStart new topic

Addition on root files

vb6_god
post 30 Jun, 2008 - 02:49 PM
Post #1


New D.I.C Head

*
Joined: 3 Dec, 2007
Posts: 25


My Contributions


Is there a way to add up for example the total amount of images stored in a folder on your root drive
and then store that value in a variable ???

much like you do when we add up all of the images in a document

e.g.

CODE


document.image.length



that gives us the total amount of images on that page , right ?

or am i being stupid lol
User is offlineProfile CardPM

Go to the top of the page


chili5
post 5 Jul, 2008 - 05:18 AM
Post #2


D.I.C Addict

****
Joined: 28 Dec, 2007
Posts: 503



Thanked 4 times
My Contributions


I don't know if with JavaScript this is possible, but you could use PHP to read all the images in the directory and then store the name in an array and count how many items are in the array.

I don't know much about JavaScript but if can scan a directory and count how many of a certain file exists, then it would be possibly but as a limited scripting language, it may not be possible.
User is online!Profile CardPM

Go to the top of the page

BetaWar
post 5 Jul, 2008 - 01:32 PM
Post #3


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,669



Thanked 64 times

Dream Kudos: 1075
My Contributions


Javascript will only be able to brute force it, meaning that if you want to you could have it go through an infinite loop trying to find all possible filenames in a certain directory. This will cause problems in a browser, and may even cause it to crash.

What you will want to do is use something like PHP or ASP to get all the images from a directory and output them into the javascript so it can calculate the number of images and use them.
User is offlineProfile CardPM

Go to the top of the page

vb6_god
post 5 Jul, 2008 - 03:55 PM
Post #4


New D.I.C Head

*
Joined: 3 Dec, 2007
Posts: 25


My Contributions


QUOTE(BetaWar @ 5 Jul, 2008 - 01:32 PM) *

Javascript will only be able to brute force it, meaning that if you want to you could have it go through an infinite loop trying to find all possible filenames in a certain directory. This will cause problems in a browser, and may even cause it to crash.

What you will want to do is use something like PHP or ASP to get all the images from a directory and output them into the javascript so it can calculate the number of images and use them.



How would i do this in ASP ?? Im ok with using VBscript but i have no idea how id check directories :S :S
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 5 Jul, 2008 - 05:56 PM
Post #5


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,669



Thanked 64 times

Dream Kudos: 1075
My Contributions


I am no master of ASP, but a quick google search did pop this up:

CODE
<%@ Language=VBScript %>
<%
option explicit

dim fs, root

set fs = createObject("scripting.filesystemobject")
set root = fs.getFolder("c:\program files")
showDiskspace fs, root
set fs = nothing

sub showDiskspace(fs, folder)

dim s

if folder.subFolders.count = 0 then
s = folder & " [" & folder.size & " kb]"
display s
exit sub
end if

dim subFolder

for each subFolder in folder.subFolders
showDiskspace fs, subFolder
next

end sub

sub display(s)

Response.Write s & "<br>"

end sub
%>  


Hopefully that makes since.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/12/08 03:38AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month