PDA

View Full Version : [CLOSED] file upload cannot handle well both failure and success



touchy
16 Jan 2014, 5:48 PM
A problem in Ext JS 4.2.2 doing file upload (observed with Ext Direct) is:

If you leave the default or clearOnSubmit:true then on failure (and on success) it clears the file field (and user has to select again to try again).

If however you set clearOnSubmit:false then neither on failure nor on success it clears. That seems OK. But ... if you think you'd in your success:function call form.reset() it doesn't clear, because it looks at the clearOnSubmit.

Which means the user by mistake might submit the same file a second time. Pain!

Me thinks part of a solution should be two separate functions in Ext.form.field.File:

One reset() function that works at any time, like all field reset().

Another function that does whatever is necessary for the special treatment for submit.

Specifically I see class Ext.form.action.DirectSubmit method doSubmit call class Ext.form.action.Submit method buildForm call class Ext.form.field.File method extractFileInput call class Ext.form.field.File method reset.

It is that Ext.form.field.File reset function that doesn't clear if clearOnSubmit:false.

Possibly that code should live (as a copy) in the extractFileInput function, and then the reset function could be simplified and actually work for application code to use in success.

This problem seems to be a consequence of work done around http://www.sencha.com/forum/showthread.php?239572 .

Gary Schlosberg
17 Jan 2014, 2:41 PM
Thanks for the report! I don't think this is a bug. It seems to be working as it was intended, especially if developers check the setting on reset. That said, I have opened a Feature Request in our tracker so this issue is considered.