JQuery hidden iframe file download

We are trying to upload a file using a hidden iframe, and the script works in all browsers except IE (9).

  • User clicks a link
  • Link launches file input to open
  • Submit file entry change triggers
  • The form is submitted in an iframe

IE9 Developer Tool returns the following error message:

SCRIPT5: Access is denied. jquery-latest.js, line 2977 character 6 

Looking around, this seems like an error that occurs next to the jQuery change() event. Honestly, this should be a simple solution ... Thank you very much if you are able to help!

HTML

 <form class="hidden" action="index.php?upload" method="POST" id="myForm" enctype="multipart/form-data" target="hidden_iframe"> <input type="file" name="userfile" id="userFile"> <input type="submit"> </form> <iframe id="hidden_iframe" class="hidden" name="hidden_iframe" src="inc/temp.html"></iframe> 

Javascript

 $('#fake').on("click",function(e){ e.preventDefault(); $('#userFile').click(); return false; }); $('#real').on("change",function(e){ e.preventDefault(); $("#myForm").submit(); }); 
+4
source share
2 answers

Perhaps you should consider an alternative solution?

Loading through a hidden iframe is not the best way to do this these days.

Look at this amazing library instead: http://www.plupload.com/

0
source

This is an IE security setting. Just go to Settings-> Internet Options-> Security-> User Level and change the security settings in the "Miscellaneous" section, set "Access to data sources by domain" to "Enable".

EDIT:

I just saw what the problem is. You start the file download and you are not allowed to do this. You must allow the user to manually click the file selection button.

+1
source

Source: https://habr.com/ru/post/1445491/


All Articles