public void UpdateImage(IFormFile file, int id)
 {
     if (file != null && file.ContentType == "image/jpeg")
     {
         service.CategoryUploadJpegImage(id, file.OpenReadStream());
     }
 }
Exemplo n.º 2
0
        public IActionResult UploadImage(UploadCategoryImageViewModel model)
        {
            string fullPath = Path.Combine(Directory.GetCurrentDirectory() + "\\wwwroot\\images\\", model.UploadFileName ?? "NoPicture.jpg");

            if (!System.IO.File.Exists(fullPath))
            {
                ModelState.AddModelError("UploadFileName", "File not found.");
                return(View(model));
            }
            service.CategoryUploadJpegImage(model.CategoryId, fullPath);
            return(new RedirectToActionResult("Index", "Categories", null));
        }