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
  • 58,060
  • 25
  • 98
  • 150
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,605
  • 2
  • 21
  • 36