summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroweissbarth2014-07-21 17:51:37 +0200
committeroweissbarth2014-07-21 17:51:37 +0200
commitdc27f9180783a8048c2dab5aea8ffbea32f2531c (patch)
tree8ea7387e36a9f4110b41fe9a2e87e3320f2f7931
parent3847239d2c05035000da2c106d83f3065dd3b3a6 (diff)
downloadfiles.iamfabulous.de-dc27f9180783a8048c2dab5aea8ffbea32f2531c.tar.gz
hopefully fixed the progress bar issue
-rw-r--r--www/browse.php1
-rw-r--r--www/static/js/dropzone.js23
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(){
</table>
</div>
<button onclick="upload()" id="button-input" class="upload-input">upload</button>
+ <p id="progress-text"></p>
</div>';
}
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);
}
}