Reputation: 20224
I have a file upload field which is part of a larger form. When a file is selected, the file should be uploaded to an API as post(?) data.
So I started with
onFilefieldChange: function(filefield, value, e0pts) {
filefield.form.submit({
url: '../api/FileUpload?type=logo',
waitMsg: 'Uploading your logo...',
success: function(fp, o) {
msg('Success', 'Processed file "' + o.result.file + '" on the server');
}
});
}
But wouldn't this submit the whole form, not just the file!?
With me, it does neither. Instead, I get the error message "Cannot call submit of undefined", but shouldn't ExtJS fill the filefield variable for me?
Last thing, can I submit the file as simple post data, or is it always "multipart form data"?
Upvotes: 2
Views: 661
Reputation: 4355
I think from your code that you need to go up
to the parent form from the field and submit and then it should be defined.
filefield.up('form').getForm().submit()
Upvotes: 3