using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Web.UI.HtmlControls; using System.IO; using System.Drawing; using System.Drawing.Imaging; namespace MOSS { public partial class StoreImageInDB : System.Web.UI.Page { protected System.Web.UI.HtmlControls.HtmlInputFile Upload; protected void Page_Load(object sender, EventArgs e) { } protected void Page_Init(object sender, EventArgs e) { try { if (Request.QueryString["id"] == null) { string id = "B0001"; Response.Clear(); Response.ContentType = "image/jpeg"; System.Drawing.Image image = RetrieveImage(id); Bitmap bmPhoto = new Bitmap(image); bmPhoto.SetResolution(72, 72); bmPhoto.Save("lkfjlk.jpeg",System.Drawing.Imaging.ImageFormat.Jpeg); bmPhoto.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); //System.IO.File.Copy( bmPhoto.Dispose(); } } catch (Exception ee) { } } private System.Drawing.Image RetrieveImage(string id) { System.Drawing.Image image = null; //command.CommandText = "SELECT Photo FROM Photos WHERE PhotoId = @PhotoId"; //command.Parameters.AddWithValue("@PhotoId", photoId); byte[] imageData = DAlAutoComplete.GetImgDB(id);//(byte[])command.ExecuteScalar(); MemoryStream memStream = new MemoryStream(imageData); image = System.Drawing.Image.FromStream(memStream); return image; } protected void OnUpload(object sender, EventArgs e) { if (FileUpload1.HasFile) { using (BinaryReader reader = new BinaryReader(FileUpload1.PostedFile.InputStream)) { byte[] image = reader.ReadBytes(FileUpload1.PostedFile.ContentLength); int i = DAlAutoComplete.ImageInsetDB(image); } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)