Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult UploadPhoto(Image img, HttpPostedFileBase file, ProfilePageModel model)
- {
- var currentUser = CommunitySystem.CurrentContext.DefaultSecurity.CurrentUser;
- bool isAccepted = false;
- string fileName = string.Empty;
- if (file.ContentLength > 0)
- {
- string fName = System.Guid.NewGuid().ToString();
- // Generate each version
- foreach (string fileKey in System.Web.HttpContext.Current.Request.Files.Keys)
- {
- HttpPostedFile uploadFile = System.Web.HttpContext.Current.Request.Files[fileKey];
- // Generate a filename (GUIDs are best).
- fileName = Path.Combine("~/uploads/", fName + format);
- // Let the image builder add the correct extension based on the output file type
- ImageBuilder.Current.Build(uploadFile, fileName, new ResizeSettings(
- "width=300;format=jpg;mode=max;crop=20,20,80,80;cropxunits=100;cropyunits=100"));
- model.fileName = fileName;
- }
- return RedirectToAction("EditProfile");
- }
- return RedirectToAction("EditProfile");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement