On form submit, file field clears in Internet Explorer 9

微笑、不失礼 提交于 2019-12-10 10:46:26

问题


I think this problem is related to this question:

Clicking submit clears file field instead of submitting the form (IE9)

I have the following form and 1 IE9 user reporting an issue. They are able to browse and select a file from their computer. But when they click the button to submit the form the image field is cleared and thus the application returns the error to 'please select an image'.

I cannot replicate the problem.

Upload a Photo (Step 1 of 2)

    <div class="box-content">
    <form encType="multipart/form-data" method="post" name="galleryuploadform" action="">
    <table>
    <tbody><tr><td class="field_name" vAlign="top" width="70">Image: <span class="red_highlight">*</span></td><td><input name="photo_image" type="file"><br>
    <span class="form_hint">All images must be:</span>
        <ul><li class="form_hint"> JPEG format (.jpg at the end)</li>
             <li class="form_hint"> RGB format</li>
                <li class="form_hint">Images will be resized to 1000x1000 on the longest edge (large size) for <a href="http://www.ephotozine.com/e2signup">e2 members</a> and 600x600 (normal size) for standard members</li></ul>

    </td></tr>
    <tr><td class="field_name" vAlign="top">Adult: </td><td><input name="photo_adult" value="1" type="checkbox"><br>
    <span class="form_hint">Tick if your photo contains adult material.<br>
<strong>Important:</strong> We do not accept pornographic images and reserve the right to delete such material. </span>
    </td></tr>
    <tr><td colSpan="2" align="center">
    <input name="action" value="Upload Photo" type="hidden">
    <input onclick="submitform('galleryuploadform');display_white_box('photo_upload_lightbox');closeKeepAlive();" name="button" value="Upload Photo" type="button"></td></tr>
    </tbody></table>
    </form>


    <div class="clear"></div></div>

we have submitform() which submits the form, display_white_box() which displays a dialog box message with 'uploading' and closeKeepAlive() which is a fix related to Safari on Mac. I have gone a javascript approach for submit because if i didn't the animated gif in the uploading dialog box would not animate.

As I said, I can't replicate it on any machine or any other browser.


回答1:


There is no solution. This an bug in Internet Explorer.




回答2:


Does your form work with a normal submit button?

It may be as Joshua Gossett said but I can't find any reference. So, I'm more asking about a JS conflict.

I don't think you should be putting an onclick event on a submit input.

A better way to do it would be to put an onsubmit attribute on the form and put a javascript function in it which dictates the action of the form when being submitted.




回答3:


I know this is an old issue, but I came across the same problem and wanted to share what worked for me.

Edit your .htaccess file by putting this in the end:

BrowserMatch MSIE best-standards-support
Header set X-UA-Compatible IE=8 env=best-standards-support

I found the information here.



来源:https://stackoverflow.com/questions/9885684/on-form-submit-file-field-clears-in-internet-explorer-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!