Upload file [original]

xiaoxiao2021-03-06  55

/ * 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 /// 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 /// /// Allowed file type, multiple "," Separate /// file size /// save the path public uploadfile (String AllfileType, DoubleLength, String SavePath) {char [] sp = {', '}; Allowfiletype = allfiletype.split (sp); filelength = fileLength; SavePath = SavePath;}

///

/// Return to the generated file name /// public string filename {get {returnifile;}}

///

/// Return error message /// public string errorMessage {get {return error;}}

///

// / According to SavePath, generate file name /// /// 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 /// /// MIME content /// 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

转载请注明原文地址:https://www.9cbs.com/read-114446.html

New Post(0)