/ * Descript: Upload file Author: Blue.dream Date: 2004-09-21 22:21 Declaration: Recently, many websites quote their article, actually omitted the author information, please quote this article not to olive Author's information. * / Namespace bdstudio.common {using system; using system.io; using system.Web; /// /// upload single file /// summary> public class uploadfile {private string [ ] AllowFileType; // Allowed file type private double filelength (kb) allowed file size (KB) Private string savepath; // File storage path Private string Savefile; // Uploaded file name Private string Error; / / Storage error message private string fileextesion; // upload file extension
/// /// Constructor /// summary> /// Allowed file type, multiple "," Separate param> /// file size param> /// save the path param> public uploadfile (String AllfileType, DoubleLength, String SavePath) {char [] sp = {', '}; Allowfiletype = allfiletype.split (sp); filelength = fileLength; SavePath = SavePath;}
/// /// Return to the generated file name /// summary> public string filename {get {returnifile;}}
/// /// Return error message /// summary> public string errorMessage {get {return error;}}
/// // / According to SavePath, generate file name /// summary> /// returns> private string makefilename (string file = this.savepath "// " System.datetime.now.year.tostring () system.datetime.now.month.tostring () system.datetime.now.day.tostring () system.datetime.now.hour.toString () System.datetime.now.minute.tostring () system.datetime.now.second.tostring () this.fileextesion; for (; file.exiss (file);) {file = this.savePath "//" System.datetime.now.year.tostring () system.datetime.now.month.tostring () system.datetime.now.day.tostring () system.datetime.now.hour.tostring () SYSTEM .Datetime.now.minute.toTString () system.datetime.now.second.tostring () this.fileextesion;} Return File;} /// // check file type /// summary > /// MIME content param> /// returns> private bool checkfileext (string fileex) {bool result = false; for (int i = 0; i < THIS.ALLOWFILETYPE.LENGTH; I ) {IF (FILEEX.INDEXOF (this.AllowFile TYPE [I] .tolower ())> -1) {result = true; Break;}} Return Result