public static string UploadDataURIscheme(System.Web.HttpServerUtilityBase server, string dataURI, out string msg) { var webUrl = string.Empty; msg = ""; try { var ext = ""; var b64 = ImageHelper.GetB64DataURIscheme(dataURI, out ext); var path = UploadHelper.CheckFileUpLoadDirectory("~", server, EnumState.UploadFileType.Avatar); var pcurl = $"{path}{Guid.NewGuid().ToString()}.{ext}"; byte[] byteArray = Convert.FromBase64String(b64); MemoryStream imgStream = new MemoryStream(byteArray); Image img = Image.FromStream(imgStream); img.Save(pcurl); webUrl = "/" + pcurl.Replace(server.MapPath("~"), "").Replace("\\", "/"); } catch (Exception ex) { msg = ex.Message; } return(webUrl); }