示例#1
0
        public static string SaveFile(HttpPostedFileBase hpf, Photo_types type)
        {
            string filename = "",
                   ext = "",
                   savedFileName = "";

            if (hpf.ContentLength == 0)
                return "";

            var settings = new ResizeSettings
            {
                MaxWidth = 450,
                MaxHeight = 350,
                Format = "jpg"
            };

            DateTime now = DateTime.Now;
            ext = Path.GetExtension(hpf.FileName);
            filename = type.ToString() + "-" + now.Millisecond + now.Second + now.Hour + now.Minute + now.Day + now.Year + ext;

            savedFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + CMS_TEMP_PATH, filename);

            ImageBuilder.Current.Build(hpf.InputStream, savedFileName, settings);
            //hpf.SaveAs(savedFileName);

            return filename;
        }
示例#2
0
        public static string movePostFile(string fileName, Photo_types photoType)
        {
            string finalPath = (photoType == Photo_types.CONTENT_PICTURE ? CMS_FINAL_PATH_CONTENT : CMS_FINAL_PATH_PROFILE);

            string sourceFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + CMS_TEMP_PATH, fileName);
            string destinationFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + finalPath, fileName);

            File.Copy(sourceFilePath, destinationFilePath);

            return ("~\\" + finalPath + "\\" + fileName);
        }