I am posting a Base64 string via Ajax to my Web Api controller. Code below
Code for converting string to Image
public static Image Base64ToImage(stri
In asp net core you can get the path from IHostingEnvironment
public YourController(IHostingEnvironment env)
{
_env = env;
}
And the method,
public void SaveImage(string base64img, string outputImgFilename = "image.jpg")
{
var folderPath = System.IO.Path.Combine(_env.ContentRootPath, "imgs");
if (!System.IO.Directory.Exists(folderPath))
{
System.IO.Directory.CreateDirectory(folderPath);
}
System.IO.File.WriteAllBytes(Path.Combine(folderPath, outputImgFilename), Convert.FromBase64String(base64img));
}