diff options
Diffstat (limited to 'www/static/js/dropzone.js')
| -rw-r--r-- | www/static/js/dropzone.js | 23 |
1 files changed, 17 insertions, 6 deletions
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); } } |
