namespace WEB.Services
{
#region 所需枚举
/// <summary>
/// 文件上传类型
/// </summary>
public enum UpLoadType
{
/// <summary>
/// 下载地址
/// </summary>
DownloadUrl = 0,
/// <summary>
/// 文件地址
/// </summary>
FileUrl = 1,
}
/// <summary>
/// 上传错误信息列举
/// </summary>
public enum WarnEnum
{
ImgContentType,
ImgContentLength,
ImgExtension,
}
#endregion
#region 文件上传基本服务类
/// <summary>
/// 文件上传基本服务类
/// </summary>
public abstract class FileUploadBase
{
/// <summary>
/// 图片MIME
/// </summary>
protected static List<string> imgMIME = new List<string>
{
"application/x-zip-compressed",
"application/octet-stream",
"application/x-compressed",
"application/x-rar-compressed",
"application/zip",
"application/vnd.ms-excel",
"application/vnd.ms-powerpoint",
"application/msword",
"image/jpeg",
"image/gif",
"audio/x-mpeg",
"audio/x-wma",
"application/x-shockwave-flash",
"video/x-ms-wmv",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
};
/// <summary>
/// 验证消息字典
/// </summary>
protected static Dictionary<WarnEnum, string> msgDIC = new Dictionary<WarnEnum, string>
{
{WarnEnum.ImgContentType ,"只能上传指定类型的文件!" },
{WarnEnum.ImgContentLength ,"只能上传文件大小为{0}以下!" },
{WarnEnum.ImgExtension , "文件的扩展文件不正确"}
};
/// <summary>
/// 相对地址字典
/// </summary>
protected static Dictionary<UpLoadType, string> relativePathDic = new Dictionary<UpLoadType, string>
{
{UpLoadType.DownloadUrl ,@"DownLoad/" },
{UpLoadType.FileUrl ,@"FileUpload/" },
};
/// <summary>
/// 图片后缀
/// </summary>
protected static string[] imgExtension = { "xls", "doc", "zip", "rar", "ppt", "docx", "xlsx", "pptx",
"mp3", "wma", "swf", "jpg", "jpeg", "gif" };
}
#endregion
}