Skip to main content

Bug Tracker

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:

http://jsfiddle.net/rPaZQ/

Attachments (0)
Change History (1)

Changed November 19, 2012 10:34PM UTC by timmywil comment:1

component: unfiledattributes
priority: undecidedlow
resolution: → plugin
status: newclosed

Sounds like this would be good for a jQuery plugin like file upload.