• elementplus 上传组件判断文件格式


    图片:
    .jpeg格式:image/jpeg
    .png格式: image/png
    .gif格式: image/gif
    
    
    音频:
    .mp3格式:audio/mpeg
    
    
    视频:
    .mp4格式:video/mp4
    .m3u8格式:application/x-mpegURL
    .mov格式:video/x-ms-wmv
    .avi格式:video/x-msvideo
    .flv格式:video/x-flv
    .wmv格式:video/x-ms-wmv
    
    
    文本:
    .xls格式:application/vnd.ms-excel
    .xlsx格式:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    .doc格式:application/msword
    .docx格式:application/vnd.openxmlformats-officedocument.wordprocessingml.document
    .txt格式:text/plain
    .pdf格式:application/pdf
    .ppt格式:application/vnd.ms-powerpoint
    .zip格式:application/zip
    .rar格式:application/x-rar
     //校验版块
            //校验---{上传成员头像}前图片格式及大小
            AvatarUpload(file) {
                const isJPG = file.type === 'image/jpeg';
                const isLt2M = file.size / 1024 / 1024 < 2;
                if(['image/jpeg','image/PNG'].indexOf(File.type) == -1) {
                    this.$message.error('上传头像图片只能是 JPG/PNG 格式!');
                    return false;
                }
                if (!isLt2M) {
                    this.$message.error('上传头像图片大小不能超过 2MB!');
                }
                return isJPG && isLt2M; 
            },
            //校验---{上传视频}前进行格式校验
            videoUpload(file) {
                const isLt50M = file.size / 1024 / 1024  < 50;
                if (['video/mp4', 'video/ogg', 'video/flv','video/avi','video/wmv','video/rmvb'].indexOf(file.type) == -1) {
                    this.$message.error('请上传正确的视频格式');
                    return false;
                }
                if (!isLt50M) {
                    this.$message.error('上传视频大小不能超过50MB哦!');
                    return false;
                }
            },
            //校验---{上传ppt}前进行格式校验
            pptUpload(file) {
            if (['application/vnd.ms-powerpoint'].indexOf(file.type) == -1) {
                    this.$message.error('请上传正确的ppt格式');
                    return false;
                }  
            },
            //校验---{上传商业企划书}前进行格式校验
            doxrUpload(file) {
                if (['application/vnd.ms-powerpoint', 'application/msword','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/pdf' ].indexOf(file.type) == -1) {
                    this.$message.error('请上传正确类型的文件格式');
                    return false;
                } 
            },
  • 相关阅读:
    Smart Client Architecture and Design Guide
    Duwamish密码分析篇, Part 3
    庆贺发文100篇
    .Net Distributed Application Design Guide
    New Introduction to ASP.NET 2.0 Web Parts Framework
    SPS toplevel Site Collection Administrators and Owners
    来自Ingo Rammer先生的Email关于《Advanced .Net Remoting》
    The newsletter published by Ingo Rammer
    深度探索.Net Remoting基础架构
    信道、接收器、接收链和信道接受提供程序
  • 原文地址:https://www.cnblogs.com/wx18638101223/p/16120921.html
Copyright © 2020-2023  润新知