View Full Version : FileUploadField in FieldContainer doesn't use extUpload

29 Sep 2011, 6:40 AM
Hi All,

I'm working on a image tool. It uses the google image api, the flickr search api and it should use the FileUploadField.

It is wrapped in a FieldContainer, so the user can choose what type image to post. And i can implement it in different forms, with a xtype field.

Its working great with the google image api and the flickr api.
However now i want the FileUploadField in it.

How do i tell the form it should use a file upload?
I tried to give the fieldcontainer a function 'isFileUpload' which returns true if its an local image instead of a selection from one of the api's. However its still an XHTTPRequest instead of the post with extUpload: true.

29 Sep 2011, 9:26 AM
How do i tell the form it should use a file upload?

You need to call the upload method on the Ext.data.Connection object that submits the form. It might be easiest to create a form dynamically, add your file upload field to it, and then submit the form.

I wrote a file upload component for ExtJS that might help you - you may be able to build what you need using it:


29 Sep 2011, 11:43 PM
I took an other good look at my code trying to fire out why it wasn't creating a multipart form.

I found out that I don't submit a form, I save a record.

Is there a way to trigger the file upload when saving the record?

here's a snippet of code :

saveAction: function() {
var me = this,
form = me.getForm(), // get the basic form
record = form.getRecord(); // get the underlying model instance

if (form.isValid()) {
record.save({ // save the record to the server
success: function(newsitem) {
Ext.Msg.alert('Succes', 'Saved successfully');
failure: function(newsitem, action) {
Ext.Msg.alert('Error', action.error);
} else { // display error alert if the data is invalid
Ext.Msg.alert('Error', 'Please enter all required fields');

30 Sep 2011, 7:14 AM
Is there a way to trigger the file upload when saving the record?

Yes, spend some time with the API documentation.

10 Oct 2011, 12:58 AM
I've searched the api docs, and the forum. However I can't find how to do this.
I found an other topic with the almost same question, and the answer to that was that it wasn't possible.