Here's a little routine I use.  The server sends back some minimal JSON 
code that I extract from the iframe that the upload form was posted to.  
This is a condensed version.  If you need more of the code (html/js), let 
me know.

If there's a more prototype-y way to do 
"document.getElementsByTagName('body')[0]", please let me know and I'll 
change my code.


var Uploader = Class.create({
    initialize: function(form, target, dir, mgr) {
        this.form = form;
        this.target = target;  //iframe
        this.dir = dir;
        this.mgr = mgr;
        
        $(this.form).observe('submit', this.upload.bind(this));
        $(this.target).observe('load', this.complete.bind(this));
    },
    
    upload: function() {
        // clear iFrame
        $(this.target).update('');
    
        // build form
        var f = $(this.form);
        f.submit();
    },
    
    complete: function() {
        try {
            var c = 
frames[this.target].document.getElementsByTagName('body')[0].innerHTML.evalJSON();
            var res = c['success'];
        }
        catch(e) {
            alert('Error.  File(s) not Uploaded');
            return;
        }
      // evaluate res here.
   }
})

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/uQH5QOV6-yYJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to