示例#1
0
        private bool CheckFile(HttpPostedFileBase fileUpload)
        {
            if (fileUpload.ContentLength == 0)
            {
                this._uploadtype = UploadUnitType.无文件上传;
                return(false);
            }
            if (fileUpload.ContentLength > UploadLength)
            {
                this._uploadtype = UploadUnitType.文件过大;
                return(false);
            }
            string Files = fileUpload.FileName;

            if (((this._uploadWith.Count > 0) && (this._uploadWith.Count == this._uploadHigth.Count)))
            {
                this._IsThumbnail = true;
            }
            if (!this.CheckExt(Files))
            {
                this._uploadtype = UploadUnitType.文件格式错误;
                return(false);
            }
            this._uploadFileExt = IOFiles.GetExtension(Files).ToLower();
            return(true);
        }
示例#2
0
 private bool CheckFilePath()
 {
     if (!SafeCheck.IsMap(this._uploadPath))
     {
         this._uploadPath = IOFiles.GetFolderMapPath(this._uploadPath);
     }
     IOFiles.CreatedFolder(this._uploadPath);
     if (IOFiles.IsFolder(this._uploadPath))
     {
         return(true);
     }
     this._uploadtype = UploadUnitType.存储文件夹错误;
     return(false);
 }
示例#3
0
        private string SaveFile(HttpPostedFileBase fileUpload)
        {
            string NewFile = string.Empty;

            try
            {
                string date         = DateTime.Now.Ticks.ToString();
                string filedate     = string.Empty;
                string dateFormat   = DateTime.Now.ToString(this._uploadFormat);
                string datapathyuan = IOFiles.CreatedFolderData(this._uploadPath, dateFormat, out filedate);
                string fileName     = filedate + date + this._uploadFileExt;
                fileUpload.SaveAs(this._uploadPath + fileName);
                this._IsSuccess = true;
                if (this.IsThumbnail)
                {
                    Thumbnail thumbnail = null;
                    if ((this._uploadWith.Count > 0) && (this._uploadHigth.Count > 0))
                    {
                        int count = 0;
                        if (this._uploadWith.Count > this._uploadHigth.Count)
                        {
                            count = this._uploadHigth.Count;
                        }
                        else
                        {
                            count = this._uploadWith.Count;
                        }
                        string resultfile = fileName;
                        for (int i = 0; i < count; i++)
                        {
                            thumbnail = new Thumbnail(this._uploadPath + fileName);
                            NewFile   = string.Concat(new object[] { filedate, date, "_", i, this._uploadFileExt });
                            thumbnail.thumbnailFile(this._uploadPath + NewFile, this._uploadWith[i], this._uploadHigth[i]);
                            if (i == 0)
                            {
                                resultfile = NewFile;
                            }
                        }
                        fileName = resultfile;
                    }
                }
                return(fileName);
            }
            catch
            {
                this._uploadtype = UploadUnitType.保存文件出错;
                return("");
            }
        }
示例#4
0
 public UploadMvc(string uploadPath)
 {
     this._uploadtype    = UploadUnitType.成功;
     this._IsSuccess     = false;
     this._uploadFileExt = string.Empty;
     this._uploadPath    = string.Empty;
     this._uploadFormat  = "yyyyMM";
     this._IsThumbnail   = false;
     this._IsSwf         = false;
     this._IsOther       = false;
     this._OtherExt      = "";
     UploadLength        = 30 * 1024 * 1024;
     this._uploadWith    = null;
     this._uploadHigth   = null;
     this._uploadPath    = uploadPath;
     this._uploadWith    = new List <int>(0);
     this._uploadHigth   = new List <int>(0);
 }