• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Need smiple Code For counting files on media card then add value to html form

Need smiple Code For counting files on media card then add value to html form.

I need help creating a code that will count the number of files in a folder, then with the information fill a form field with the number so it will be submited with the form.
0
kwitcom
Asked:
kwitcom
  • 3
  • 3
  • 2
  • +1
6 Solutions
 
RoonaanCommented:
kwitcom,

Although my knowledge on this matter is somewhat limited, the one thing I can tell you is that when security does its job, you would not be able to do this using clientside scripting.
Using serverside languages which have access to the media card, you would be able to count files and output the number of files using a generated form, but in general, languages like javascript or vbscript cannot perform this task.

-r-
0
 
kwitcomAuthor Commented:
Well this is on a Private network that i have full access on and i can change the rights to do what i want.
0
 
COBOLdinosaurCommented:
Ihas nothing to do with rights or privileges.  By design browsers pages no not hav acess to client resources.  It would be such a huge security hole that it is not optional and there is not setting that can be changed.  

However if the page is served up from the local computer using a file: protocol then you can access the hard drive, but you will still need programming to get what yo want becasue conventional client web page languages do not have the methods necessary to interact with the file systemon local computer except to make simple load request.  you will have to embed some Java or activex to get what you want

Cd&
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RoonaanCommented:
Using the suggestion on local file systems by COBOLdinosaur you could try using vbscript and
createObject("scripting.FileSystemObject");
However I am not sure wether or not this would be working without needing a lot of tweaks.

-r-
0
 
COBOLdinosaurCommented:
Yeah fso is usable aslong as activex is enabled.

Wsh as well.

Cd&
0
 
kwitcomAuthor Commented:
Well this is being run from the local system that i have installed IIS on to be able to run the page... Another option might be to run a script when the page loads that counts and creates a pop-up with the number which the user can re-type into the form.
0
 
jaydeeukCommented:
I have done something similar across a network. All it did was look for files on computers and index them in to a database. Saying that browsers do not have access to the local file system is not strictly true.
The easiest way is to make the drive a shared resource with read access (Iwam account and Iusr)
Then make a variable in ASP telling the code where the share is located, and then as someone suggested, use the filesystem object to loop thru all the directories (recursive loop will work best) indexing all the files, and write out the total.


Another way would be using a HTA application. This gets round most of the security problems with normal HTML pages and gives you full access to the local file system. The limitations of this is that the HTA will probably need to be run on the same computer as the one with the drive you wish to access, although i have never tried to access a remote computer (assuming you have full read/write privilages)

0
 
COBOLdinosaurCommented:
>>>Saying that browsers do not have access to the local file system is not strictly true.

As a matter of fact, no one said that.  It was indicated that browser pages do not have access to client resources.  That is 100% accurate.  

When a web page is served from the file system on a local machine, the file system is host the browser pages still do not have access.  When HTA is used the windows is the host.  When FSO is used; that is an active x object.  For Any ASP solution it is obvious that the web page is not the agent of access because ASP runs on the host server.

So let's try and keep thesemantics accurate;  especially when we are dealing with M$ only solutions that bypass normal security, and invite developer to build things that cannot be suppoert outside of the narow place they built it in.

Cd&
0
 
kwitcomAuthor Commented:
This is what i found to use.... i have it saved as a .vbs file and i can edit to the path i need.

File: c1.vbs

Set fs = CreateObject("Scripting.FileSystemObject")
folderName = "c:\music"
Wscript.echo fs.GetFolder(folderName).Files.Count

output: 2xxxxxx

This works great... it is a popup box but works.... Thanx all for help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now