This commit is contained in:
2026-01-17 01:12:40 +07:00
parent 85afe2badc
commit db9f958243
6 changed files with 485 additions and 403 deletions

View File

@@ -140,6 +140,16 @@
this.fileInput.addEventListener('change', () => this.updatePreview());
}
formatFileSize(bytes) {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
}
updatePreview() {
const file = this.fileInput.files[0];
@@ -151,7 +161,7 @@
this.previewContainer.style.display = 'block';
this.info.innerHTML = `
<div><strong>Name:</strong> ${file.name}</div>
<div><strong>Size:</strong> ${formatBytes(file.size)}</div>
<div><strong>Size:</strong> ${this.formatFileSize(file.size)}</div>
<div><strong>Type:</strong> ${file.type || 'Unknown'}</div>
`;