public IActionResult SaveCategory(AddCategoryVM model) { string uniquefileName = null; if (model.Image != null) { string uploadsFolder = Path.Combine(hosting.WebRootPath, "images"); uniquefileName = Guid.NewGuid().ToString() + "_" + model.Image.FileName; string filePath = Path.Combine(uploadsFolder, uniquefileName); model.Image.CopyTo(new FileStream(filePath, FileMode.Create)); } Category category = new Category { CategoryName = model.categoryName, ImageUrl = uniquefileName }; _Iproduct.AddCategory(category); return(Redirect("/Administration/Index")); }