1

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

tereško
  • 57,247
  • 24
  • 95
  • 149
Tarik Koc
  • 53
  • 1
  • 4

1 Answers1

3

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;
Community
  • 1
  • 1
tsukimi
  • 1,595
  • 2
  • 19
  • 35