View Full Version : [FIXED] [4.0.2] Form reset not working for file upload field

3 Aug 2011, 4:22 AM

Ext version tested:

Ext 4.0.2
Browser versions tested against:

IE 8.0.7
FF 5.0.1
Chrome 12.0.74
Opera 11.50

Form reset does not work for file upload fields. The chosen file name remains in the upload field after reset, despite the fact that internally the value of the field appears to be cleaned. Also, it's possible to submit the form after a reset despite 'allowBlank: false'.
Steps to reproduce the problem:
Open the file upload example at:
Press 'Save' without filling any fields.
Fill 'Name' and 'Photo' fields (Photo by choosing a file from the file system). Press 'Reset'
Press 'Save'
Fill 'Name', press 'Save'
The result that was expected:
Both fields show errors
The values in both fields get reset
Both fields show errors
Form not submitted, the 'Photo' field shows error.
The result that occurs instead:
Both fields show errors (CORRECT)
'Name' gets reset correctly, but the file name remains in the 'Photo' field. (INCORRECT)
Only the 'Name' field shows an error. (INCORRECT)
Form submitted, the following message is displayed in the alert: 'Processed file "" on the server'. (INCORRECT)
Test Case:



See this URL for live test case:

Operating System:

Windows 7 Ultimate

5 Aug 2011, 4:51 AM
Any ideas? Anyone?

5 Aug 2011, 6:21 AM
Yes, I've written file uploads. The only way to reset is to recreate the <input type='file'> element. I'm surprised this was not like that already.

I'll create a ticket.

5 Aug 2011, 6:27 AM
'K, it does recreate the file input. It just does not reset that text input which you see there.

5 Aug 2011, 6:32 AM
Thanks Animal :)

Is there some simple workaround for now (a quick override or something) or should I just wait for the next version of Ext? When do you think this could be fixed?

5 Aug 2011, 6:34 AM
Fixed for 4.0.6

5 Aug 2011, 6:36 AM
Your workaround should be:

Ext.form.field.File.prototype.reset = Ext.Function.createInterceptor(Ext.form.field.File.prototype.reset, function() {
this.inputEl.dom.value = '';

5 Aug 2011, 6:59 AM
Thanks a lot Animal - the fix works! =D>

I've just verified it under all the browsers mentioned in the bug description. The only small problem I see now is that under IE, after supplying the file and pressing 'Reset' you instantly get an error message next to the field ('This field is required'). In contrast, for the 'Name' field, after pressing 'Reset' you get the error message only when you try to save the form. For me personally this problem can be ignored.
Thanks again,


18 Nov 2014, 6:45 AM
I have a same kind of scenario.
There is a text area, i have configured it as allowBlank:false. While reseting the form i am getting the
validation Error "This Field is Required".

I saw the documentation it says that reset () will clear all the validations, then why i am getting the Required Field Error.

This Error is coming only in IE. Any suggestions ?