Base64 문자열 바이너리 흐름으로 파일을 서버에 저장

8220 단어 C#
/// /// Base64 /// /// Base64 /// public static Dictionary<string, string> decodeBase64ToImage(string dataURL) { if (string.IsNullOrEmpty(dataURL)) return new Dictionary<string, string>(); var Current = HttpContext.Current; string path = "/UserFile/Files/Attach/" + DateTime.Now.ToString("yyyyMMdd"); string savepath = Current.Server.MapPath("~/" + path); if (!Directory.Exists(savepath)) Directory.CreateDirectory(savepath); string filepath = ""; string imgName = "face_" + ALUtils.GetGUID() + ".JPEG"; ;// string try// ,try,catch { filepath = path + "/" + imgName;// string savepathfile = savepath + "/" + imgName;// FileStream fs = new FileStream(savepathfile, FileMode.Create, FileAccess.Write); BinaryWriter bw = new BinaryWriter(fs); byte[] arr = Convert.FromBase64String(dataURL); bw.Write(arr); fs.Close(); bw.Close(); } catch (Exception ex) { AddLgoToTXT(ex.Message + " " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } var dic = new Dictionary<string, string>(); dic.Add(imgName, filepath); return dic;// }

좋은 웹페이지 즐겨찾기