Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 6th, 2005, 11:54 PM
Authorized User
Join Date: Sep 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get the length of Attachment

Hi All,

I want to know the length of a attachment in java script is it possible?

It is always safe to assume, not that the old way is wrong, but that there may be a better way...
Old January 7th, 2005, 12:15 AM
Friend of Wrox
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel

   <title>Check the Size of a File -- Javascript</title>

    <script language="JavaScript">
    function CheckFileSize()
        var objSize = new ActiveXObject("Scripting.FileSystemObject");
        var strFileName = objSize.getFile(document.frmFileUpload.strFile.value);
        var SizeOfFile = strFileName.size;
        alert(SizeOfFile + " bytes");
    <form name="frmFileUpload">
        <input type="file" name="strFile">
        <input type="button" name="btnSize" value="Show file size" onClick="CheckFileSize();">
The above code snippet will work only if ActiveX is supported @ the client end.

Best Regards


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail attachment surendran PHP How-To 0 August 3rd, 2006 06:05 AM
Attachment alannoble26 Excel VBA 3 January 9th, 2006 01:47 PM
length crmpicco Classic ASP Basics 1 February 11th, 2005 11:24 AM
mail-attachment sureshdev786 General .NET 0 December 27th, 2004 09:34 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.