添加文件大小限制

This commit is contained in:
luyuan 2020-11-17 15:07:54 +08:00
parent 8371a7188f
commit 6e19aa583d
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
2 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,4 @@
/**
* Base64
*/
@ -79,10 +80,21 @@ export function provenimg(file: any): boolean | void{
* @param name
*/
export function provenvideo(file: any): boolean{
export function provenvideo(file: any, isvideo?: boolean): boolean{
const type = ['flv', 'mp4', 'wmv', 'mov', 'avi'];
const ntypearr = file.name.split('.');
const ntype = ntypearr[ntypearr.length - 1];
if(isvideo){
const size = 500 * 1024 * 1024;
if(file.size > size){
return false;
}
}else{
const size = 100 * 1024 * 1024;
if(file.size > size){
return false;
}
}
for(const i in type){
if(type[i] == ntype){
return true;

View File

@ -330,7 +330,7 @@ export default defineComponent({
}
}
function video(file: any){
return provenvideo(file)
return provenvideo(file, true)
}
function imgs(file: any){
return provenimg(file)