ie javascript form submit with file input

后端 未结 8 533
-上瘾入骨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 18:12

    I found the answer myself, After 2 days of crazy trial&error. I hope I can help somebody with this..

    I removed the hidden file input field from my coldfusion page and replaced it by an iframe tag. That iframe tag linked to another coldfusion page, containing another form with the removed file input field. Now when I use javascript to click the file input field, which is still hidden from view, it still gives the browse file dialog without a hitch. But when I use javascript to submit the form, through the iframe, miraculously, it submits the form in the iframe, making it possible to upload the file in some serverside scripting of your preference.

    iframe code:

    iframe itself:

    
    

    javascript click & submit:

    ifu.document.formFileUpload.partnersLogo.click();
    ifu.document.formFileUpload.submit();
    

提交回复
热议问题