public IActionResult UpladProjectImage(ProjectImageChangeViewModel model) { if (ModelState.IsValid) { try { if (model.Image.Length > 0) { if (!model.Image.ContentType.StartsWith("image")) { throw new Exception("Csak képfájlok tölthetőek fel!"); } string filePath = $"{_env.WebRootPath}/images/projects/{model.ProjectId}.jpg"; using (var stream = System.IO.File.Create(filePath)) { model.Image.CopyTo(stream); } } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return(PartialView("UpladProjectImage", model)); }
public IActionResult ChangeProjectImage(int projectId) { ProjectImageChangeViewModel model = new ProjectImageChangeViewModel() { ProjectId = projectId }; return(PartialView("UpladProjectImage", model)); }