Clicking submit clears file field instead of submi

2019-02-02 14:59发布

问题:

I got a weird error I hope you guys can help with.

Sometimes when the user tries to submit a form the file upload field image just clears and nothing happens. I doesn't seems like the form get submitted at all.

Then the day after everything works fine. The error occurs on random days/times.

First I thought it was a problem with the users computer but this happens on two different computers the customer has. One of the computers has Windows 7 professional & Internet Explorer 9. I don't have the setup on the other one.

I have tried with Google Chrome, Firefox 6.0.2, Internet Explorer 9, 8 (browser compatibility mode), 7 (browser compatibility mode) on windows 7 home with no problems at all on my computer.

Here is the form:

<form action="/user/image" method="post" accept-charset="utf-8" class="form_default" enctype="multipart/form-data">
    <fieldset>
        <ol>
            <li>
                <button type="submit" name="save" value="submit" class="button">Save</button>
            </li>
            <li>
                <label for="image">Profile image</label><input type="file" id="image" name="image" />
            </li>
            <li>
                <button type="submit" name="save" value="submit" class="button">Save</button>
            </li>
        </ol>
    </fieldset>
</form>

回答1:

There should be only 1 submit button per form. So keep 1 save button as type="submit" ,change another to type="button"



回答2:

Try using input instead of button, good luck!

ex

<input type="submit" name="mysubmit" value="Click!" />


回答3:

you should use:

<input type="button" onclick="customFunction" />

write what you want to do in customFunction(javascript)



回答4:

There is no clever workarounds for this, IE9 does not allow a file to be tampered with via JavaScript probably for security reasons.



回答5:

First of all, pls let us see your php coding to send this form.... Usually form submission errors such as this have server-side coding errors.. Maybe you should check out your PHP coding and see what happens in your

 $_POST['save'] 

area....

Hope this helps... :)