Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCRIPT5: Access is denied in IE9 on file upload

When posting a form with a file upload box using document.forms[0].submit() on ie 9 we get an error that says: SCRIPT5: Access is denied

If I click a few more times it works fine.

As a work around I've caught the error and try a few more times which seems to work just fine.

Is there any explanation on this? The code has worked for years on all the other popular browsers.

The code also works fine in IE9 if the browser is set to IE9 compatibility mode, but that is not something we have general control over.

I've seen references to XMLHTTP being an issue and we do execute a XMLHTTP call but it happens before the button to submit is clicked.

like image 507
Tom Hubbard Avatar asked May 26 '11 12:05

Tom Hubbard


1 Answers

It turns out that the security issue is due to the fact that we were running the file submit code in a pop up window. The pop up window was opened with window.open which had an empty string as the requested page. We then posted a form to that window.

The problem is that the URL of the pop up window is defaults to about:blank when not specified. Apparently about:blank is considered insecure so when the attempt to POST the file back to the originating domain is made the SCRIPT5: Access is denied error arises.

The solution is to use a small stub type of html page to open and then perform the post. Once a file is chosen the FILE post does not see the error and the file makes it up as desired.

like image 133
Tom Hubbard Avatar answered Sep 21 '22 06:09

Tom Hubbard