简体   繁体   中英

Javascript returns wrong file size, when using ASP.NET (aspx pages) for uploading

I am uploading a file in an ASP.NET application, I need to get the file size for some client side validation. Following the advice I found here . I have something like this:

in aspx:

<td class="form_input_bold">
            <asp:FileUpload Width="80%" ID="fuUploadFile" CssClass="button" runat="server" Font-Names="Verdana" />                
        </td>

And in Javascript:

var inputFile = document.getElementById('ctl00_ContentPlaceHolder1_fuUploadFile');
alert("File size: " + inputFile.size);

Now for some reason, when I try to upload a 50 MB file, inputFile.size returns 20. Can anyone tell why this is? ASP.NET is getting the correct size server side..

在输入控件的files数组的元素中找到文件的大小。

var numBytes = document.getElementById("fu1").files[0].size;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM