How to get file size in Client Machine using scripts?

N

Nabanit Barooah

Hi,

We are working on a Web Application (in ASP.NET). The application basically
deals with uploads from the client machine. We need to check the size of the
file that will be uploaded. The size must be known in the client - side of
the application, so that proper validations can be done before the user tries
to upload the file.

One way of resolving this issue is by using File System Object in JavaScript
or using Create Object in VBScript. But this has got some security issues -
we need to enable an Internet Option "Initialise and Script ActiveX object
not marked as safe". We are looking for any other alternative approach. It
will be very helpful if anyone can suggest some solutions.
Code we are using in JavaScript:

var objFSO, objFile, fileSize;
objFSO = new ActiveXObject("Scripting.FileSystemObject");
objFile = objFSO.GetFile(document.all.item("File1").value);
fileSize = objFile.Size;

Regards,
Nabanit Chandra Barooah
 
G

Göran Andersson

You can't access the client file system from Javascript. You have to put
an ActiveX component or Java applet on the page to get that kind of
access. That of course means that the user has to accept that the
component is started.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top