burger
This commit is contained in:
@@ -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>
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user