0

I have a fileupload control, I want to validate the size of the file to 50kb before the done button is clicked.

I did some research on the internet and got this code

<script>
   function A() {
      var oas = new ActiveXObject("Scripting.FileSystemObject");
      var d = document.a.b.value;
      var e = oas.getFile(d);
      var f = e.size;
      alert(f + " bytes");
   }
</script>

I am using IE9 but this code is not working for me. I am getting error on the line

var oas = new ActiveXObject("Scripting.FileSystemObject");

How to solve this error?

Michal Klouda
  • 14,263
  • 7
  • 53
  • 77
user1681166
  • 221
  • 2
  • 5
  • 15

2 Answers2

0

Try this approach, i think it's much more user friendly. It also prevents you from many browser / ActiveX related problems.

http://codes.codedigest.com/CodeDigest/65-File-Size-Validation-in-FileUpload-control-in-ASP-Net.aspx

Tys
  • 3,592
  • 9
  • 49
  • 71
0

ActiveX need to be enabled in your browser safety setting, did you check it?

Alain BUFERNE
  • 2,016
  • 3
  • 26
  • 37