javascript - IE doesn't support file upload in a dynamic form? -
javascript - IE doesn't support file upload in a dynamic form? -
if explicitly write out form in html this:
<form action='upload_1-img.php' enctype='multipart/form-data' method='post'> <input type='file' id='image' name='image'><input type='submit'> </form>
then goes expected in ie. if following, works in chrome , ff not in ie8:
<html> <head> <script> $(document).ready(function(){ imgform = document.createelement('form'); imgform.id = 'imgform'; imgform.method='post'; imgform.enctype='multipart/form-data'; imgform.action ='upload_1-img.php'; $('body').append(imgform); $('#imgform').append("<input type='file' id='image' name='image' /><input type=submit>"); }); </script> </head> <body> </body> </html>
in case, if utilize var_dump($_files)
in upload_1-img.php
, returns empty array. ie8 uploads file when same form explicitly coded in html. need file upload work after form created dynamically in javascript. what's workaround create work in ie8?
try doing this:
var form=document.createelement("<form id='imgform' action='upload_1-img.php' enctype='multipart/form-data' method='post'>"); $('body').append(form); $('#imgform').append("<input type='file' id='image' name='image' /><input type=submit>");
source: http://verens.com/2005/07/06/ie-bugs-dynamically-creating-form-elements/
if check bottom of article, states
the above code work in ie, except when need utilize multipart aspect of (uploading file, example), when barf.
in case, ie seems insist on next crappy code:
form=document.createelement('<form action="shoppingcart_xhr.php" method="post" > enctype="multipart/form-data" target="shoppingcart_iframe">');
javascript forms internet-explorer file-upload internet-explorer-8
Comments
Post a Comment