19.4 系统设置文件的实现
系统设置文件ASPNETAJAXWeb.cs的主要功能是设置系统中数据函数的参数,即上传文件的存放目录,缩略图的存放目录,水印图片的存放目录,创建缩略图的宽度和高度,每次上传文件的数量限制,允许上传文件类型的限制,允许上传图片类型的限制等。
文件ASPNETAJAXWeb.cs的主要实现代码如下。
// 上传文件的存放地址
public const string STOREFILEPATH = "Files/";
// 缩略图的存放地址
public const string STORETHUMBIMAGEPATH = "SuoImages/";
// 水印图片存放的地址
public const string STROEWATERMARKIMAGEPATH = "ShuiImages/";
// 缩略图的默认宽度和高度
public const int THUMBWIDTH = 200;
public const int THUMBHEIGHT = 150;
// 每次最大上传文件的数量
public const int MAXFILECOUNT = 10;
// 允许上传的文件类型
public static string[] ALLOWFILELIST = new string[]{
".ani",".arj",".avi",".awd",
".bak",".bas",".bin",".cab",
".cpx",".dbf",".dll",".doc",
".dwg",".fon",".gb",".gz",
".hqx",".htm",".html",".js",
".lnk",".m3u",".mp3",".mpeg",
".mpg",".njx",".pcb",".pdf",
".ppt",".ps",".psd",".pub",
".qt",".ram",".rar",".sch",".scr",
".sit",".swf",".sys",".tar",".tmp",
".ttf",".txt",".vbs",".viv",".vqf",
".wav",".wk1",".wq1",".wri",".xls",
".zip",".bmp",".cur",".gif",".ico",
".jpg",".jpeg",".mht",".pdf",".png"
};
// 允许上传的图像类型
public static string[] ALLOWIMAGELIST = new string[]{
".bmp",".cur",".gif",".ico",".jpg",".jpeg",".png"
};
……
// 缩略图的缩放方式
public enum ThumbMode
{
FixedWidth = 0, // 指定缩略图的宽度
FixedHeight = 1, // 指定缩略图的高度
FixedWidthHeight = 2, // 指定缩略图的宽度和高度
FixedRatio = 3 // 指定缩略图与原图的比率
}