From: edward Date: Mon, 14 Mar 2016 03:38:05 +0000 (+0800) Subject: Roo/bootstrap/UploadCropbox.js X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=8e5ca389e82135bdfda2b56aab66322312ba50a6;p=roojs1 Roo/bootstrap/UploadCropbox.js --- diff --git a/Roo/bootstrap/UploadCropbox.js b/Roo/bootstrap/UploadCropbox.js index 1472edf229..0808b401d8 100644 --- a/Roo/bootstrap/UploadCropbox.js +++ b/Roo/bootstrap/UploadCropbox.js @@ -1279,6 +1279,56 @@ Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, { }, + uploadFromSource : function(file, crop) + { + this.xhr = new XMLHttpRequest(); + + this.xhr.open(this.method, this.url, true); + + var headers = { + "Accept": "application/json", + "Cache-Control": "no-cache", + "X-Requested-With": "XMLHttpRequest" + }; + + for (var headerName in headers) { + var headerValue = headers[headerName]; + if (headerValue) { + this.xhr.setRequestHeader(headerName, headerValue); + } + } + + var _this = this; + + this.xhr.onload = function() + { + _this.xhrOnLoad(_this.xhr); + } + + this.xhr.onerror = function() + { + _this.xhrOnError(_this.xhr); + } + + var formData = new FormData(); + + formData.append('returnHTML', 'NO'); + + formData.append('crop', crop); + + if(typeof(file.filename) != 'undefined'){ + formData.append('filename', file.filename); + } + + if(typeof(file.mimetype) != 'undefined'){ + formData.append('mimetype', file.mimetype); + } + + if(this.fireEvent('prepare', this, formData) != false){ + this.xhr.send(formData); + }; + }, + prepare : function(file) { this.file = false;