Bug 8248 - Can not clear file input field
Summary: Can not clear file input field
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 417.x
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Darin Adler
Depends on:
Reported: 2006-04-07 10:12 PDT by Barry Kaplan
Modified: 2007-04-22 16:35 PDT (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Barry Kaplan 2006-04-07 10:12:19 PDT
I am using an AJAX to submit/upload a file to my server. This works perfectly. After I get the response I want to clear the form to allow the user to upload another file. This does not work.

1) Setting the value of the file input element to "" does nothing.
2) Calling form.reset does nothing
3) removing the element and adding a new file element does nothing.

Currently the only way to get this to work is by exploiting this bug# 5196.
Comment 1 Ben Jamieson 2006-05-30 06:29:50 PDT
I'm lost as to why this is marked as unconfirmed?

Its actually worse than the AJAX implementation outlined in the initial report, and affects any form, using just plain old HTML.

Create a form with a file upload element.

Select a file.

Now decide you don't want to upload a file at this stage and clear the field.

You can't. Confirmed...

...and a serious PIA for anyone using Safari on a regular basis. 

All other browsers let you simply delete the file path. Safari does not.

Please fix this.
Comment 2 Joost de Valk (AlthA) 2006-05-30 06:31:44 PDT
Well the reason for it being unconfirmed is quite simple. Nobody with the right to confirm it has yet confirmed it :). I'll look into it when i get home and have access to webkit.
Comment 3 Ben Jamieson 2006-05-30 06:49:24 PDT
(In reply to comment #2)
> Well the reason for it being unconfirmed is quite simple. Nobody with the right
> to confirm it has yet confirmed it :). 

Aah, that would make sense! <grin> 
Thanks for stopping by our little bug and taking the time to respond!

Comment 4 Dave Hyatt 2006-05-30 13:20:04 PDT
Resetting the form should clearly work.  Poking the value of a file upload control is not allowed in Safari.
Comment 5 Darin Adler 2007-04-22 09:05:51 PDT
The three things mentioned here are potentially three separate bugs, so they might need separate bug reports. I'm tackling (2) first.
Comment 6 Darin Adler 2007-04-22 09:39:38 PDT
I have a patch that deals with issues (1) and (2). I think that issue (3) is a separate bug and needs a separate bug report and test case.
Comment 7 Darin Adler 2007-04-22 16:35:13 PDT
Sending        WebCore/ChangeLog
Sending        WebCore/html/HTMLInputElement.cpp
Adding         WebCore/manual-tests/clear-input-file.html
Sending        WebCore/platform/FileChooser.cpp
Sending        WebCore/platform/FileChooser.h
Sending        WebCore/rendering/RenderFileUploadControl.cpp
Transmitting file data ......
Committed revision 21010.