From dc27f9180783a8048c2dab5aea8ffbea32f2531c Mon Sep 17 00:00:00 2001 From: oweissbarth Date: Mon, 21 Jul 2014 17:51:37 +0200 Subject: hopefully fixed the progress bar issue --- www/browse.php | 1 + www/static/js/dropzone.js | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/www/browse.php b/www/browse.php index 32edf1a..5741b45 100644 --- a/www/browse.php +++ b/www/browse.php @@ -118,6 +118,7 @@ function get_upload(){ +
'; } diff --git a/www/static/js/dropzone.js b/www/static/js/dropzone.js index f4e3399..ead87c6 100644 --- a/www/static/js/dropzone.js +++ b/www/static/js/dropzone.js @@ -70,7 +70,7 @@ var vfs_upload_queue = []; xhr.upload.filename = vfs_upload_queue[i].name; - xhr.open('post', document.URL, true); + var data = new FormData(); data.append("userfile", vfs_upload_queue[i]); @@ -81,14 +81,25 @@ var vfs_upload_queue = []; data.append("path", folder); - xhr.onreadystatechange=function(){ - if (xhr.readyState==4 && xhr.status==200){ + xhr.onload=function(){ + if (xhr.status==200){ + alert("upload done"); + }else{ + alert("upload failed"); } }; - xhr.upload.addEventListener("progress", function(e){ - document.getElementById("progressBar-"+this.filename).value = Math.ceil(e.loaded/e.total)*100; - }); + xhr.upload.onprogress= function(e){ + if(e.lengthComputable){ + document.getElementById("progressBar-"+this.filename).value = Math.ceil(e.loaded/e.total)*100; + document.getElementById("progress-text").innerHTML = Math.ceil(e.loaded/e.total)*100 + "%"; + }else{ + alert("cant compute progress"); + } + }; + + xhr.open('post', document.URL, true); + xhr.overrideMimeType('text/plain; charset=x-user-defined-binary'); xhr.send(data); } } -- cgit v1.2.3