using System; namespace FredCK.FCKeditorV2 ...{ publicabstractclass FileWorkerBase : System.Web.UI.Page ...{ privateconststring DEFAULT_USER_FILES_PATH ="/UserFiles/"; privateconststring DEFAULT_USER_FILES_UPLOADTYPE =".jpg.jpeg.bmp.gif.png.zip.rar.swf.";//默认允许上传文件类型 privateconstint DEFAULT_USER_FILES_UPLOADSIZE =1024;//默认允许上传文件大小(1024KB) privatestring sUserFilesPath; privatestring sUserFilesDirectory; privatestring sUserUploadType; privateint iUserUploadSize =0; protectedstring UserFilesPath ...{ get ...{ if (sUserFilesPath ==null) ...{ // Try to get from the "Application". sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"]; // Try to get from the "Session". if (sUserFilesPath ==null|| sUserFilesPath.Length ==0) ...{ sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"]; // Try to get from the Web.config file. if (sUserFilesPath ==null|| sUserFilesPath.Length ==0) ...{ sUserFilesPath = System.Web.Configuration.WebConfigurationManager.AppSettings["FCKeditor:UserFilesPath"]; // Otherwise use the default value. if (sUserFilesPath ==null|| sUserFilesPath.Length ==0) sUserFilesPath = DEFAULT_USER_FILES_PATH; // Try to get from the URL. if (sUserFilesPath ==null|| sUserFilesPath.Length ==0) ...{ sUserFilesPath = Request.QueryString["ServerPath"]; } } } // Check that the user path ends with slash ("/") if (!sUserFilesPath.EndsWith("/")) sUserFilesPath +="/"; } return sUserFilesPath; } } /**////<summary> /// The absolution path (server side) of the user files directory. It /// is based on the <see cref="FileWorkerBase.UserFilesPath"/>. ///</summary> protectedstring UserFilesDirectory ...{ get ...{ if (sUserFilesDirectory ==null) ...{ // Get the local (server) directory path translation. sUserFilesDirectory = Server.MapPath(this.UserFilesPath); } return sUserFilesDirectory; } } /**////<summary> /// 获取允许上传的类型 ///</summary> protectedstring UserUploadType ...{ get ...{ if (sUserUploadType ==null) ...{ // Try to get from the "Application". sUserUploadType = (string)Application["FCKeditor:UserUploadType"]; // Try to get from the "Session". if (sUserUploadType ==null|| sUserUploadType.Length ==0) ...{ sUserUploadType = (string)Session["FCKeditor:UserUploadType"]; // Try to get from the Web.config file. if (sUserUploadType ==null|| sUserUploadType.Length ==0) ...{ sUserUploadType = System.Web.Configuration.WebConfigurationManager.AppSettings["FCKeditor:UserUploadType"]; // Otherwise use the default value. if (sUserUploadType ==null|| sUserUploadType.Length ==0) sUserUploadType = DEFAULT_USER_FILES_UPLOADTYPE; } } // Check that the user path starts and ends with slash (".") if (!sUserUploadType.StartsWith(".")) sUserUploadType ="."+ sUserUploadType; if (!sUserUploadType.EndsWith(".")) sUserUploadType +="."; } return sUserUploadType; } } /**////<summary> /// 获取允许上传的文件最大限制 ///</summary> protectedint UserUploadSize ...{ get ...{ if (iUserUploadSize <1) ...{ iUserUploadSize = Convert.ToInt32(Application["FCKeditor:UserUploadSize"]); if (iUserUploadSize <1) ...{ iUserUploadSize = Convert.ToInt32(Session["FCKeditor:UserUploadSize"]); if (iUserUploadSize <1) ...{ iUserUploadSize = Convert.ToInt32(System.Web.Configuration.WebConfigurationManager.AppSettings["FCKeditor:UserUploadSize"]); if (iUserUploadSize <1) ...{ iUserUploadSize = DEFAULT_USER_FILES_UPLOADSIZE; } } } } return iUserUploadSize; } } } }