C#base64 article:
Base64 and Image Transfer chapter:
Todo:
Base64 and Image transfer chapter: mainly on the basis of business needs to develop picture display and picture preservation
Todo:
1, add page, save path name
2, view page, data from other tables, read base64 data format picture conversion to picture display
Explanation: 1, add page, save path name 2, view page, data from other table, read Base64 data format picture converted to picture display
1, add page, save path name
<%@ page language= "C #" autoeventwireup= "true" codebehind= "Event.aspx.cs" inherits= "HMFW. Web.Pages.AndroidAPP.Event "%><! DOCTYPE html>
Using system;using system.data;using system.configuration;using system.web;using system.web.security;using System.web.ui;using system.web.ui.webcontrols;using system.web.ui.webcontrols.webparts;using System.web.ui.htmlcontrols;using system.collections.generic;using system.linq;using System.IO;namespace HMFW. web.pages.androidapp{public partial class Event:System.Web.UI.Page {protected void Page_Load (object Sende            R, EventArgs e) {} protected void Bthupload1_serverclick (object sender, EventArgs e) {            String strpath = Uploadpic (file1); if (string.            IsNullOrEmpty (strpath)) return;            IMG1.SRC = strpath;        Hidimg1.value = strpath; } protected void Bthupload2_serverclick (object sender, EventArgs e) {string strpath = Uploadpic (            FILE2); if (string.            IsNullOrEmpty (strpath)) return;            IMG2.SRC = strpath; Hidimg2.value = strpath; } protected string Uploadpic (HtmlInputFile control) {if (string. IsNullOrEmpty (Control.            Postedfile.filename)) return "";            The folder path where the picture is saved, string path = Server.MapPath ("/upload/android/");            A folder for uploading pictures per day is a string of folders = DateTime.Now.ToString ("YyyyMMdd"); If the folder does not exist, create an if (!            Directory.Exists (path + folder)) {directory.createdirectory (path + folder); }//Upload a picture with the extension string type = control. PostedFile.FileName.Substring (Control.            PostedFile.FileName.LastIndexOf ('. ')); The file name of the saved picture is string savename = Guid.NewGuid ().            ToString () + type; Save the picture control.            Postedfile.saveas (path + folder + "/" + savename);        Return "/upload/android/" + folder + "/" + savename; } protected void Delpic1_click (object sender, EventArgs e) {if (File.exists (Server.MapPath. Src)) {FileInfo fi = new FileInfo (Server.MapPath (IMG1.SRC)); Fi.                Delete ();            Hidimg1.value = ""; }} protected void Delpic2_click (object sender, EventArgs e) {if (File.exists (Server.mapp                Ath (img2.src)) {FileInfo fi = new FileInfo (Server.MapPath (IMG2.SRC)); Fi.                Delete ();            Hidimg2.value = ""; }        }    }}
2, view page, data from other tables, read base64 data format picture conversion to picture display<%@ page language= "C #" autoeventwireup= "true" codebehind= "EventHandleTempView.aspx.cs" inherits= "HMFW. Web.Pages.AndroidAPP.EventHandleTempView "%><! DOCTYPE html>Using HMFW. Bll. Sqjs. Zjwg;using HMFW. Model;using system;using system.collections.generic;using system.io;using system.linq;using System.Text;using System.web;using system.web.ui;using system.drawing;using system.web.ui.webcontrols;namespace HMFW. web.pages.androidapp{public partial class EventHandleTempView:System.Web.UI.Page {protected string spicle Ngth {get {return viewstate["spiclength"] = = null? string. empty:viewstate["Spiclength"]. ToString ();        } set {viewstate["spiclength"] = value;}        } EVENTBLL IBLL = new EVENTBLL (); protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {String imgid = request.querystring["Imgid"];//picture id int id = Convert . ToInt32 (request.querystring["id"]);//default First picture int spiclength = Convert.ToInt32 (request.querystring["Spicleng TH "]);//Specifies the length of the picture stream loops through the display of the specified picture (multiple references) Spiclength = Spiclength.tostrING ();                Sq_event sqeventsearch = new Sq_event ();                Sqeventsearch.gid = new Guid (imgid); Sq_event model = IBLL.                Getmodel (Sqeventsearch);                        try {if (model! = NULL && spiclength >= 2) {                        String base64decode = Model.sPicPath.Split (', ') [ID];                        byte[] bt = convert.frombase64string (Base64decode);                        System.IO.MemoryStream stream = new System.IO.MemoryStream (BT);                        Bitmap Bitmap = new Bitmap (stream); Bitmap.                    Save (Response.outputstream, System.Drawing.Imaging.ImageFormat.Gif);                }} catch (Exception ex) {throw ex;            } response.end (); }        }    }}
Base64 and image in accordance with the specific business requirements of the mutual transfer