1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    8
    Vote Rating
    0
    mr.amin0 is on a distinguished road

      0  

    Default Unanswered: FileUploadField in FieldContainer doesn't use extUpload

    Unanswered: FileUploadField in FieldContainer doesn't use extUpload


    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.

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2011
    Posts
    33
    Vote Rating
    0
    m4dc4p will become famous soon enough

      0  

    Default


    Quote Originally Posted by mr.amin0 View Post
    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:

    http://m4dc4p.github.com/uploader/

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    8
    Vote Rating
    0
    mr.amin0 is on a distinguished road

      0  

    Default


    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 :
    Code:
       saveAction: function() {
            var me = this,
                form = me.getForm(), // get the basic form
                record = form.getRecord(); // get the underlying model instance
    
    
            if (form.isValid()) {
                form.updateRecord(record);
                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');
            }
        },

  4. #4
    Ext JS Premium Member
    Join Date
    Mar 2011
    Posts
    33
    Vote Rating
    0
    m4dc4p will become famous soon enough

      0  

    Default


    Quote Originally Posted by mr.amin0 View Post
    Is there a way to trigger the file upload when saving the record?
    Yes, spend some time with the API documentation.

  5. #5
    Sencha User
    Join Date
    Jul 2011
    Posts
    8
    Vote Rating
    0
    mr.amin0 is on a distinguished road

      0  

    Default


    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.
    http://www.sencha.com/forum/showthre...C-architecture

Thread Participants: 1

Tags for this Thread