Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > How to get file size in Client Machine using scripts?

Reply
Thread Tools

How to get file size in Client Machine using scripts?

 
 
Nabanit Barooah
Guest
Posts: n/a
 
      05-10-2006
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
 
Reply With Quote
 
 
 
 
Göran Andersson
Guest
Posts: n/a
 
      05-13-2006
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.

Nabanit Barooah wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FAQ 9.6 How do I download a file from the user's machine? How do I open a file on another machine? PerlFAQ Server Perl Misc 0 04-09-2011 04:00 PM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Get file size on client machine ? Poppy ASP General 1 04-13-2004 12:02 PM



Advertisments