html - jQuery submit() not working in IE when an <input type="file"> is in the form -
i want use submit input trigger click in file input , submit form itself. clicking in submit button open file picker window, , after closes form submitted. i'm using code:
<?php var_dump($_files); echo "<br>".time(); ?> <!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $(document).ready(function() { $("#uploadform").submit(function() { $("#file", this).click(); return false; }); $("#uploadform #file").change(function() { $(this).closest("#uploadform").unbind('submit').submit(); }); }); </script> </head> <body> <form id="uploadform" name="uploadform" method="post" enctype="multipart/form-data"> <input type="file" name="file" id="file" style="position:absolute; top:0; left:0; visibility: hidden"> <input type="submit" value="submit"> </form> </body> </html>
in ff , webkit works fine, in ie form not submitted when calling submit(). can tell because current time generated php @ top of page doesn't change. tried submitting form inside settimeout() call, no dice. have no errors in console or anywhere else.
ie has safety check, if user has not physically clicked on file upload button themselves, not submit form.
you cannot use javascript them.
Comments
Post a Comment