# Automation server cant create object - File Validation problem in IE 8 and 9



## madhmurt (May 14, 2012)

My code contains file validation where I check for the file extension. My code works fine in all browsers (IE7, Firefox, Safari, Chrome) except for IE8 and IE9. Following is the code that I have, I am using JQuery


```
<script type="text/javascript">
document.domain ='standard.com';
$('.fileUploadClass').bind('change',validateFile);
function validateFile(){
//alert("Inside validateFile");
var inputBoxes = $('.fileUploadClass');
var ext = $(this).val().split('.').pop().toLowerCase();
var fileName = $(this).val();
var tokens = fileName.split('\\');
fileName = tokens[tokens.length-1];
var fileNameLen = fileName.length;
 
if($.browser.msie){
    var activeObj1 = new ActiveXObject("Scripting.FileSystemObject");
    var fileval = this.value;
    var currentFile = activeObj1.getFile(fileval);
    var currentFileSize = currentFile.size;
    }else{
    currentFileSize = this.files[0].fileSize;
    }
if($.inArray(ext,['doc','docx','xls','xlsx','tif','png','jpeg','bmp','txt','rtf','pdf','csv','jpg','gif','ppt','pptx','tiff']) == -1){
  document.getElementById(this.id+'ErrorText').innerHTML="This file type cannot be accepted. Please select a different document or clear this field.";
  $('#'+this.id+'Error').addClass("app_boxed app_errorField");
  $('#'+this.id+'ErrorText').remove("app_errorText");
  document.getElementById(this.id+'ErrorText').style.display="block";
}
}
</script>
<div id="fileupload3" >
    <h:form name="upload3"  id="upload3Form" action="" method="POST" enctype="multipart/form-data">    
     <div id="FileUpload3Error">
        <div id="FileUpload3ErrorText"></div>
        <div class="fileupload-buttonbar">
          <label class="fileinput-button">  
            <input type="file" name="fileupload3" id="FileUpload3" class="fileUploadClass"></input>
 
          </label>
          <button type="button" class="app_buttonText" onclick="clearUpload('3');this.form.reset();">Clear
            </button>
        </div>
     </div>
    </h:form>   
  </div>

Problem is that when my html page is rendered in IE8 or 9 browser I get the below error and my file validation does not run.

Message: Automation server can't create object
Line: 1453
Char: 5
Code: 0
URI: [url]https://myportal.somestandard.com/w/p/services/eieio/!ut/p/b1/hY3bCoJAFEW_pR_wnBlv46MaZDUNombOvIhZhOKlQBT9-uwDpP22YS0WKJAEdZ1Qk1oMMlBdMVavYqj6rmh-X1m5jSk9xKFJ2Dky8chpQoI0IOjQFZArgBtz8Z9_gwyNPK7Z-zIPGV_8MamXGAUvJ7G4s1iKWYggfKTR1XPd-rPnCk6gqnurTWWroWZTS0fDNhwklDHUQQR9-wS5hu3NMEdIQPrQqoabXr_7Ag3_tQI!/[/url]
```
After doing some research I found that the problem is with the creation of ActiveXobject. Fundamental problem with the above code in IE8 and 9 is the below line
var activeObj1 = new ActiveXObject("Scripting.FileSystemObject");

After searching through forums, I found few options and below are the options that I tried but none of them worked for me.
1) Tools --> Internet Options --> Security --> Trusted Sites --> Added the website to the zone
2) Tools --> Internet Options --> Security --> Internet --> Custom Level --> ActiveX Controls and Plug-ins --> Enable
3) Tools --> Internet Options --> Security --> Internet --> Custom Level --> Set the custom level to Meduim

Request you to please provide me any alternative approaches or how to make sure the above code works, especially ActiveXobject getting created. This is the same problem which I face in IE9 as well.

My operating system is Microsoft Windows XP Professional version 2002 with service pack 3.

Your help is highly appreciated.
Thanks,
Madhu


----------



## Corday (Mar 3, 2010)

Moved from IE forum as per discussion with madhmurt.


----------



## Laxer (Dec 28, 2010)

Hi Madhmunt,

What are you trying to accomplish with this script?

I am curious as it will decide what approach I take with the file validation.


----------

