public static string SaveImage(this string fullpath, WebImage image, bool isThumb = true, int width = 470, int height = 227) { var filename = image.FileName; fullpath.CreateDirIfNotExist(); image.Save(fullpath + filename); if (isThumb) { image.Resize(width, height); image.Save(fullpath + "thumb_" + filename); } return filename; }
//public static string SaveLinkImage(this string fullpath, string imgpath, string url) //{ // var request = (HttpWebRequest)WebRequest.Create(imgpath); // var response = (HttpWebResponse)request.GetResponse(); // WebImage image = new WebImage(response.GetResponseStream()); // var filename = url.Trim().Replace(".", "").Replace(" ", "_").Replace("&", "").Replace("?", "").Replace("@", "").Replace(":", "").Replace("/", ""); // image.Save(fullpath + filename, "png"); // return filename + ".png"; //} public static string SaveFile(this string fullpath, HttpPostedFileBase file) { var filename = file.FileName; fullpath.CreateDirIfNotExist(); file.SaveAs(fullpath + filename); return filename; }