\\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);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter