input限制上传的文件大小
需要限制input
上传的文件大小
默认 `input` 上传文件的单位为 Byte (字节)
单位换算
1024Byte = 1KB
1024KB = 1MB
1024MB = 1GB
<el-form-item label ="上传文档:" prop="filePath">
<input type="file" class="fl" id="batchImport" ref="batchImport" :accept="accept" name="batchImport" style="display: none;" @change="showWord($event)"/>
<button id="upload" class="upload_btn" type="button" @click="uploadWord">请选择文档</button>
<span id="document_name">{
{wordResult}}</span>
<div class="el-form-item__error" v-if="isError">请选择上传文档</div>
</el-form-item>
const file = document.getElementById('batchImport').files[0]
const fileMaxSize = 1024*1024*100
if (file.size > fileMaxSize) {
this.$utils.showTip('error','','文档大小不超过100M!','文档大小不超过100M!')
} else {
uploadReport(this);
}
还没有评论,来说两句吧...