\\upload string wwwRootPath = _webHostEnvironment.WebRootPath; string fileName = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); string fileWebPath = Path.Combine(@"~\file\path", fileName).Replace('\\', '/'); string filePath = Path.Combine(wwwRootPath, @"file\path", fileName); using (FileStream fileStream = new FileStream(filePath, FileMode.Create)) { file.CopyTo(fileStream); }