protected void btnUploadImgPicture1_ServerClick(object sender, EventArgs e) { using (filePicture1) { if (filePicture1.PostedFile.FileName != "") { imageUtil = new ImageUtility(); string realPhysicalPath = Path.Combine(Server.MapPath("~/upload/"), filePicture1.PostedFile.FileName); filePicture1.PostedFile.SaveAs(realPhysicalPath); //imgVehiclePicture1.Src = realPhysicalPath; using (imgVehiclePicture1) { imgVehiclePicture1.Attributes["src"] = imageUtil.getBase64String(realPhysicalPath); Session.Add("Image1", realPhysicalPath); imageUtil = null; } } } } public string getBase64String(string path) { Image img = Image.FromFile(path); byte[] imageBytes = imageToByteArray(img); string base64String = Convert.ToBase64String(imageBytes, 0, imageBytes.Length); return "data:image/png;base64," + base64String; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)