Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. public ActionResult UploadPhoto(Image img, HttpPostedFileBase file, ProfilePageModel model)
  2. {
  3. var currentUser = CommunitySystem.CurrentContext.DefaultSecurity.CurrentUser;
  4. bool isAccepted = false;
  5.  
  6. string fileName = string.Empty;
  7. if (file.ContentLength > 0)
  8. {
  9. string fName = System.Guid.NewGuid().ToString();
  10. // Generate each version
  11. foreach (string fileKey in System.Web.HttpContext.Current.Request.Files.Keys)
  12. {
  13. HttpPostedFile uploadFile = System.Web.HttpContext.Current.Request.Files[fileKey];
  14. // Generate a filename (GUIDs are best).
  15. fileName = Path.Combine("~/uploads/", fName + format);
  16.  
  17. // Let the image builder add the correct extension based on the output file type
  18. ImageBuilder.Current.Build(uploadFile, fileName, new ResizeSettings(
  19. "width=300;format=jpg;mode=max;crop=20,20,80,80;cropxunits=100;cropyunits=100"));
  20. model.fileName = fileName;
  21. }
  22. return RedirectToAction("EditProfile");
  23. }
  24. return RedirectToAction("EditProfile");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement