fd.append('f', f); var xhr = new XMLHttpRequest(); xhr.open('POST', '?' + new URLSearchParams({op:'upload', d:curPath})); xhr.upload.onprogress = function(e) { if (e.lengthComputable) { document.getElementById('upbar' + i).style.width = (e.loaded/e.total*100) + '%'; } }; xhr.onload = function() { var d = JSON.parse(xhr.responseText); document.getElementById('upst' + i).innerHTML = d.s === 'ok' ? '✓ ' + formatSize(d.b) + '' : '✗ failed'; if (i === files.length - 1) loadDir(curPath); }; xhr.onerror = function() { document.getElementById('upst' + i).innerHTML = 'error'; }; xhr.send(fd); }); } // Drag & drop var dz = document.getElementById('dropZone'); dz.addEventListener('dragover', function(e) { e.preventDefault(); dz.classList.add('over'); }); dz.addEventListener('dragleave', function() { dz.classList.remove('over'); }); dz.addEventListener('drop', function(e) { e.preventD