- // this.xhr.upload.addEventListener("progress", function(e) {
- // if (e.lengthComputable) {
- // var percentage = Math.round((e.loaded * 100) / e.total);
- // self.ctrl.update(percentage);
- // }
- // }, false);
-
- // xhr.upload.addEventListener("load", function(e){
- // self.ctrl.update(100);
- // var canvas = self.ctrl.ctx.canvas;
- // canvas.parentNode.removeChild(canvas);
- // }, false);
- console.log(file);
- xhr.open("PUT", this.uploadUrl + '/' + file.name);
- xhr.setRequestHeader("Content-Type", file.type);
- // xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
+
+ addListener(req.upload, 'progress', function(evt){self.progressHandler(evt);});
+ addListener(req.upload, 'load', function(evt){self.uploadCompleteHandler(evt);});
+
+ req.open("PUT", this.uploadUrl + '/' + file.name);
+ req.setRequestHeader("Content-Type", file.type);
+ addListener(reader, 'load', function(evt){req.sendAsBinary(evt.target.result);});
+ reader.readAsBinaryString(file);
+};
+
+DDFileUploader.prototype.uploadCompleteHandler = function(evt) {
+ this.progressBar.parentNode.removeChild(this.progressBar);
+};
+
+DDFileUploader.prototype.progressHandler = function(evt) {
+ if (evt.lengthComputable) {
+ var progress = evt.loaded / evt.total;
+ this.updateProgressBar(progress);
+ this.previewImg.style.opacity=progress;
+ }
+};
+
+DDFileUploader.prototype.previewUploadedImage = function(file) {
+ var reader = new FileReader();
+ var img = this.previewImg;
+ var size = this.thumbnailSize;
+
+ img.className = 'hidden';
+