ie javascript form submit with file input

后端 未结 8 530
-上瘾入骨i
-上瘾入骨i 2020-12-02 17:35

I have a html form, with a custom file upload field. And by that I mean that I have moved the actual file field beyond the borders of the page with css, that I have a custom

8条回答
  •  攒了一身酷
    2020-12-02 17:46

    This is an old post but the problem still arises. This may not be working because jQuery kindly fails silently. I was having this problem and wondering why my hidden form would not submit and the file get uploaded. I started off by using jQuery, but then I went vanilla. It still didn't work but looked as though an exception was being thrown in my .click() function.

    Running

    try {
        document.getElementById('formid').submit();
    } catch (e) {
        alert(e);
    }
    

    showed that we indeed were throwing an error, and quick research showed that this was because IE DOES NOT SUPPORT SIMULATED CLICKS ON A FILE INPUT. This means that when the form went to be posted, IE would refuse to post the form

    Excuse the bold caps, but I know many people will see text and not read it

提交回复
热议问题