Side navigation
#12917 closed bug (plugin)
Opened November 19, 2012 03:34PM UTC
Closed November 19, 2012 10:34PM UTC
input type[file] can't be reset with val('') in IE (+ workaround)
Reported by: | matthew@mastracci.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | attributes | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Due to IE's inane security manager, you can't set the value of an input[file], even to "" to reset it.
There's a workaround that might be useful to pull into jQuery. It wraps a form around the input element, calls reset on it, then removes the parent element:
http://stackoverflow.com/questions/1043957/clearing-input-type-file-using-jquery/13351234#13351234
function reset(e) {
e.wrap('<form>').closest('form').get(0).reset();
e.unwrap();
}
This workaround works in all browsers:
Attachments (0)
Change History (1)
Changed November 19, 2012 10:34PM UTC by comment:1
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → plugin |
status: | new → closed |
Sounds like this would be good for a jQuery plugin like file upload.