public async Task <IActionResult> AddLeague(AddLeagueModel model, IFormCollection LeagueImage) { //var webRoot = _environment.WebRootPath; //string leagueId = Convert.ToString(LeagueImage["Id"]); string storePath = "/images/leagues/"; var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", "images", "leagues", LeagueImage.Files[0].FileName); using (var stream = new FileStream(path, FileMode.Create)) { await LeagueImage.Files[0].CopyToAsync(stream); } var league = new Leagues { LeagueName = model.LeagueName, CountryId = model.CountryId, LeagueImageUrl = storePath + model.LeagueImage.FileName }; await _leagueService.Create(league); return(RedirectToAction("Index", "Leagues")); }