C# Base64 String to JPEG Image Posted on 2017-03-21 | Post modified 2019-04-22 Client傳base64字串到後端並儲存成圖片,透過C# 延續:Check size and compress the picture Save ImageC Sharp1234567891011121314151617string path = HttpContext.Current.Server.MapPath("../img/user_share/" + guid);try{ byte[] bytes = Convert.FromBase64String(base64String); System.Drawing.Image image; using (MemoryStream ms = new MemoryStream(bytes)) { image = System.Drawing.Image.FromStream(ms); image.Save(path + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); } return true;}catch (Exception ex){ return false;} Note Server.MapPath對應至 Web 伺服器上的實體檔案路徑 path。