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
  • 13,903
  • 7
  • 51
  • 74
user1681166
  • 211
  • 2
  • 4
  • 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,480
  • 7
  • 46
  • 68
0

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

Alain BUFERNE
  • 1,868
  • 2
  • 22
  • 35