diff --git a/paste.html b/paste.html index 3b47d34..0d2cf52 100644 --- a/paste.html +++ b/paste.html @@ -78,13 +78,18 @@ } function update_file_status() { + const status = document.getElementById('file_stats'); + if (this.files[0] === undefined) { + status.textContent = '0 bytes'; + return; + } let bytes = this.files[0]?.size ?? 0; let size = bytes + ' bytes'; const units = ['KiB', 'MiB', 'GiB', 'TiB']; for (let i = 0, approx = bytes / 1024; approx > 1; approx /= 1024, i++) { size = approx.toFixed(3) + ' ' + units[i]; } - document.getElementById('file_size').textContent = `${this.files[0]?.type ?? 'application/application/octet-stream'}, ${size}`; + status.textContent = `${this.files[0]?.type ?? 'application/application/octet-stream'}, ${size}`; } function toggle_password() {