Friday, August 23, 2013

How to find ASP.NET file upload control file size using javascript ?

The ASP.NET file upload control selected file size can be obtained on javascript. The below code snippet access the fup control object and get the size of the file.

<script type="text/javascript">

        function GetFileSize() {


            <asp:FileUpload ID="fupUserPhoto" runat="server" />
            <br />
            <input type="button" id="btnGetSize" value="Get file size" onclick="GetFileSize()" />

The size of the file will be returned in byte.