Adding xhr upload binary to _upload xhr function

Hi valumns,

Please introduce my self, Im Didin, Im one of your upload javascript library fan :)

I send you pull request to what I have modified on your great javascript upload library.
The background is:

I csrf protection cannot passed when I try uploading file with xhr upload class.
so I modify some line at _upload method inside xhr upload class.

so the finally upload function is like this:

_upload: function(id, params){
        var file = this._files[id],
            name = this.getName(id),
            size = this.getSize(id);
                
        this._loaded[id] = 0;
                                
        var xhr = this._xhrs[id] = new XMLHttpRequest();
        var self = this;
                                        
        xhr.upload.onprogress = function(e){
            if (e.lengthComputable){
                self._loaded[id] = e.loaded;
                self._options.onProgress(id, name, e.loaded, e.total);
            }
        };

        xhr.onreadystatechange = function(){            
            if (xhr.readyState == 4){
                self._onComplete(id, xhr);                    
            }
        };

        var Tools = {

            init : function(file, name, params){
                this._paramsFile(file, name);
                this._params(params);
                var request  = "--" + this._getBoundary() + this._CRLF;
                    request += this._contents.join("--" + this._getBoundary() + this._CRLF);
                    request += "--" + this._getBoundary() + "--" + this._CRLF;
                return request;
            },
            
            _contents : [],
            _boundary : null,
            _CRLF : "\r\n",
            
            _getBoundary : function(){
                if(!this._boundary){
                    this._boundary = "-------------" + (new Date).getTime();
                }
                return this._boundary;
            },

            _paramsFile : function(file, name){
                var contentPart = "";
                contentPart  = 'Content-Disposition: form-data; ';
                contentPart += 'name="qqfile"; ';
                contentPart += 'filename="' + name + '"' + this._CRLF;
                contentPart += "Content-Type: application/octet-stream";
                contentPart += this._CRLF + this._CRLF;
                contentPart += file.getAsBinary() + this._CRLF;
                this._contents.push(contentPart);
                return this._contents;
            },

            _params : function(params){
                var contentPart = "";
                for(var key in params){
                    contentPart  = 'Content-Disposition: form-data; ';
                    contentPart += 'name="' + key + '"' + this._CRLF  + this._CRLF ;
                    contentPart += params[key] + this._CRLF ;
                    this._contents.push(contentPart);
                }
                return this._contents;
            },

            contentType : function(){
                return "multipart/form-data; boundary=" + this._getBoundary();
            }
        }       

            
        // build query string
        params = params || {};
        params['qqfile'] = name;
        var queryString = qq.obj2url(params, this._options.action);

        xhr.open("POST", queryString, true);
        xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
        xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
        xhr.setRequestHeader("Content-Type", "application/octet-stream");
        
        try{
            var data = Tools.init(file, name, params);
            xhr.setRequestHeader("Content-Type",Tools.contentType());
            xhr.sendAsBinary(data);            
        } catch(e){
            xhr.send(file);
        }
    },

when we catch the post input with xhr function, we don't need more using stream context with PHP (in this case) because all request will be catch with $_FILES and $_POST.

How do you think Andrew?
I looking forward your reply Valumns :).

Thanks,

Didin