예제 #1
0
        public string UploadPic(Media Media, string MediaScale, int WaterMark, int smallPiexl, string WaterImagePath, int waterPosition, string UploadType)
        {
            UpLoadMedia    upLoadMedia = new UpLoadMedia();
            string         upfilepath  = HttpContext.Current.Request.QueryString["Filedata"]; //取得上传的对象名称
            HttpPostedFile upfile      = HttpContext.Current.Request.Files[upfilepath];

            if (upfile == null)
            {
                return("请选择图片");
            }
            upLoadMedia.WaterPath  = WaterImagePath;
            upLoadMedia.MediaScale = MediaScale;
            if (MediaScale == "h")
            {
                upLoadMedia.ThumbNail_Height = smallPiexl;
            }
            else
            {
                upLoadMedia.ThumbNail_Width = smallPiexl;
            }
            upLoadMedia.WaterPostion = waterPosition;

            string msg = upLoadMedia.fileSaveAs(upfile, WaterMark);

            if (!string.IsNullOrEmpty(UpLoadMedia.UploadPath))
            {
                if (UploadType == "add")
                {
                    Media.MediaClassId  = Media.MediaClassId;
                    Media.MediaTitle    = Media.MediaTitle;
                    Media.UploadTime    = DateTime.Now;
                    Media.UploadPath    = UpLoadMedia.UploadPath;
                    Media.MediaSize     = UpLoadMedia.MediaSize;
                    Media.MediaType     = Media.MediaType;
                    Media.Uploader      = UserCookies.AdminName;
                    Media.MediaLabel    = Media.MediaLabel;
                    Media.MediaDescript = Media.MediaDescript;
                    MediaBLL.Add(Media).ToString();
                }
                else
                {
                    Media.MediaId       = Media.MediaId;
                    Media.MediaClassId  = Media.MediaClassId;
                    Media.MediaTitle    = Media.MediaTitle;
                    Media.UploadTime    = DateTime.Now;
                    Media.UploadPath    = UpLoadMedia.UploadPath;
                    Media.MediaSize     = UpLoadMedia.MediaSize;
                    Media.MediaType     = Media.MediaType;
                    Media.Uploader      = UserCookies.AdminName;
                    Media.MediaLabel    = Media.MediaLabel;
                    Media.MediaDescript = Media.MediaDescript;
                    MediaBLL.Update(Media).ToString();
                }
                upfile.InputStream.Close();
                upfile.InputStream.Dispose();
                return("操作成功");
            }
            else
            {
                return(msg);
            }
        }