简体   繁体   中英

MVC FileUpload file size client side validation

How can I validate file size from client side. It can be controlled via controller like,

if (file.ContentLength > 1048600) { } also on client side I can control name and extension of file. But how control size?

<input type="file" name="file" id="file" />

Thanks

I dont think there is currently a cross browser way to do what you want, check this question

This can work only in webkit based browsers for example

var size = document.getElementById('file').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