I have an ExtJS FormPanel with different form items (textfields, numeric etc) in some cases I need an addtional file upload in this form.
(In my opinion) The best solution would be a extJs filefield in the FormPanel, which starts the upload as soon as a file is selected by the user. After uploading the file successfully (getting {success: true, fileid: 17} from the server) the filefield should disappear and a text message (“File upload was successful”) should be shown instead. Additionally to the text message a (new) hidden input with the fileid has to be added to the FormPanel:
- User selects file with ExtJs filefield.
- Upload is started immediately (onChange).
- Server answers with success: true and fileId
- Text “File upload was successful” replaces the filefield
- hidden form item with fileId is added to the form
Is there any way to achieve this (or a similar solution) with ExtJS 4?
Easiest way is to wrap
filefieldin panel and replace content in handler. Example: