Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Many Files in a Folder 1

Status
Not open for further replies.

jerschab

Programmer
Apr 17, 2001
10
US
Hey all. I tried reading past posts and they were a little helpful, but could use a specific answer here. I want to detect how many files are in particular folders on the server using client-side javascript. My naming convention is "1.jpg, 2.jpg" etc...

I noticed advice to loop until error or until no error AND advice to use "onError" when using such a loop...I have only general ideas and have never seen how to do this (I know how to use loops, just not with this particular case)...

Can someone please show me a specific script example of how to find the highest numbered *.jpg in my folder? Thanks.
 
i must be missing something:
CLIENT side is a client side, & you can't get whatever from your server with CLIENT side javascript..

may be Server Side Java Script? but i haven't messed with this stuff yet.. Victor
 
Victor is right.
You need FileSystemObject.
Basically for sequrity reasons you cannot use it for client side, it has to be server-side.
Can you use asp?
I could post the asp code for your question.
D.
 
OK, forget the terminology for a second (although you both are obviously correct) - but I still need to do this dynamically. Is ASP the best way? I've experimented with ASP a little with an access database. Perhaps you can show me the ASP code and/or explain to me the javascript method of checking for an error (as discussed generally in a past post from someone on this website).
 
Hello,
ASP may be not the best way, but it is a correct way of doing something on the server-side.
on Error technique is a specific for ASP/VBScript pages.
See

JavaScript does not have technique for catching run-time errors, as far as I know. Buddies here can correct me, if I'm not right.

So basic example would be:
<%
On Error Resume Next
'Do something ... loop, etc.
If (Err.Number<>0) Then Response.Write Err.Number Else Response.Write &quot;OK&quot; End If
%>

If you still need code for FileSystemObject, post again -here or in ASP forum.
(I usually follow also ASP forum.)

D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top