Results 1 to 10 of 10

Thread: FileUpload response in ASP

  1. #1

    Default FileUpload response in ASP

    I am trying to upload a file to the server.
    The file upload correctly, but I have a bug in "success."
    What should be the response from the server in ASP?

    Thnaks.

  2. #2
    Sencha User
    Join Date
    Mar 2008
    Posts
    566

    Default

    Have you tried?

    <%
    Response.Write("{success: true}")
    %>

    Marty

  3. #3

    Default

    Thanks Marty,

    Yes, I tried

    This is the code:

    buttons: [{
    text: 'Enviar',
    handler: function(){
    if(fp.getForm().isValid()){
    fp.getForm().submit({
    url: 'subir.asp',
    waitMsg: 'Uploading ...',
    success: function(fp, o){
    msg('Envio', 'Fichero enviado al servidor');
    }
    });
    }
    }
    },{
    text: 'Reset',
    handler: function(){
    fp.getForm().reset();
    }
    }]
    });


    IE error :
    It was hoped an object

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Did you read the 'File uploads' section in the BasicForm API docs?

  5. #5

    Default

    response in my ASP file es:

    Response.ContentType = "text/html"
    response.write("{success: true}")


    Is correct ????

    Thanks,

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    I assume you meant 'response' (small r)?

    Yes, that seems correct. Can you try adding a failure method and check the failureType?

  7. #7
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    I'm beginning to think that the file load listener on the IFRAME that receives the response needs to fire an event through the Ext.data.Connection object to which users can add listeners to that they can see, test and manipulate the DOM document created in the IFRAME before the machinery attempts to "scrape" JSON from it.

  8. #8
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Unfortunately, due to the controversial "privatization" of methods in Ext.data.Connection, you can't override doFormUpload, but I suggest this:

    Code:
        function doFormUpload(o, ps, url){
            var id = Ext.id(),
                doc = document,
                frame = doc.createElement('iframe'),
                form = Ext.getDom(o.form),
                hiddens = [],
                hd,
                encoding = 'multipart/form-data',
                buf = {
                    target: form.target,
                    method: form.method,
                    encoding: form.encoding,
                    enctype: form.enctype,
                    action: form.action
                };
                
            Ext.apply(frame, {
                id: id,
                name: id,
                className: 'x-hidden',
                src: Ext.SSL_SECURE_URL // for IE
            });     
            doc.body.appendChild(frame);
            
            // This is required so that IE doesn't pop the response up in a new window.
            if(Ext.isIE){
               document.frames[id].name = id;
            }
            
            Ext.apply(form, {
                target: id,
                method: POST,
                enctype: encoding,
                encoding: encoding,
                action: url || buf.action
            });
            
            // add dynamic params            
            ps = Ext.urlDecode(ps, false);
            for(var k in ps){
                if(ps.hasOwnProperty(k)){
                    hd = doc.createElement('input');
                    hd.type = 'hidden';                    
                    hd.value = ps[hd.name = k];
                    form.appendChild(hd);
                    hiddens.push(hd);
                }
            }        
    
            function cb(){
                var me = this,
                    // bogus response object
                    r = {responseText : '',
                         responseXML : null,
                         argument : o.argument},
                    doc,
                    firstChild;
    
                try{ 
                    doc = frame.contentWindow.document || frame.contentDocument || WINDOW.frames[id].document;
                    this.fireEvent("uploadresponse", doc);
                    if(doc){
                        if(doc.body){
                            if(/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)){ // json response wrapped in textarea                        
                                r.responseText = firstChild.value;
                            }else{
                                r.responseText = doc.body.innerHTML;
                            }
                        }
                        //in IE the document may still have a body even if returns XML.
                        r.responseXML = doc.XMLDocument || doc;
                    }
                }
                catch(e) {}
    
                Ext.EventManager.removeListener(frame, LOAD, cb, me);
    
                me.fireEvent(REQUESTCOMPLETE, me, r, o);
                
                function runCallback(fn, scope, args){
                    if(Ext.isFunction(fn)){
                        fn.apply(scope, args);
                    }
                }
    
                runCallback(o.success, o.scope, [r, o]);
                runCallback(o.callback, o.scope, [o, true, r]);
    
                if(!me.debugUploads){
                    setTimeout(function(){Ext.removeNode(frame);}, 100);
                }
            }
    
            Ext.EventManager.on(frame, LOAD, cb, this);
            form.submit();
            
            Ext.apply(form, buf);
            Ext.each(hiddens, function(h) {
                Ext.removeNode(h);
            });
        }

  9. #9

    Default

    Firebug reported de net error:

    msg is not defined

    what is this ???

  10. #10

    Default

    Change msg for Ext.Msg.alert and work fine !!!!!!!!!!!

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •