fix: 6MB limit for preview images (client + server)
This commit is contained in:
@@ -231,7 +231,10 @@ const PageMarket = {
|
|||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
const inp = document.createElement('input'); inp.type = 'file'; inp.accept = 'image/*';
|
const inp = document.createElement('input'); inp.type = 'file'; inp.accept = 'image/*';
|
||||||
inp.style.display = 'none'; inp.id = 'pub-preview-input';
|
inp.style.display = 'none'; inp.id = 'pub-preview-input';
|
||||||
inp.onchange = function() { previewFile = this.files[0]; const el = document.getElementById('pub-preview-file'); if(el){el.textContent=previewFile?previewFile.name:'';el.style.display=previewFile?'':'none'} };
|
inp.onchange = function() {
|
||||||
|
previewFile = this.files[0];
|
||||||
|
if (previewFile && previewFile.size > 6291456) { Toast.show('预览图不能超过 6MB', 'error'); previewFile = null; this.value = ''; }
|
||||||
|
const el = document.getElementById('pub-preview-file'); if(el){el.textContent=previewFile?previewFile.name:'';el.style.display=previewFile?'':'none'} };
|
||||||
document.body.appendChild(inp); inp.click();
|
document.body.appendChild(inp); inp.click();
|
||||||
} else { previewFile=null; const o=document.getElementById('pub-preview-input');if(o)o.remove(); const el=document.getElementById('pub-preview-file');if(el)el.style.display='none' }
|
} else { previewFile=null; const o=document.getElementById('pub-preview-input');if(o)o.remove(); const el=document.getElementById('pub-preview-file');if(el)el.style.display='none' }
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user