I tried this code for displaying image preview without saving in database but it showing 4 errors please help me sir
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["Image"] = null;
}
}
protected void Upload(object sender, EventArgs e)
{
Session["Image"] = FileUpload1.PostedFile;
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
byte[] bytes = br.ReadBytes((Int32)fs.Length);
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
Image1.ImageUrl = "data:image/png;base64," + base64String;
Panel1.Visible = true;
}
protected void Save(object sender, EventArgs e)
{
HttpPostedFile postedFile = (HttpPostedFile)Session["Image"];
postedFile.SaveAs(Server.MapPath("~/Uploads/") + Path.GetFileName(postedFile.FileName));
Response.Redirect(Request.Url.AbsoluteUri);
}
protected void Cancel(object sender, EventArgs e)
{
Response.Redirect(Request.Url.AbsoluteUri);
}
}
Error 1 The type or namespace name 'Stream' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\SANCHANA\My Documents\Visual Studio 2008\WebSites\WebSite39\Default.aspx.cs 25 9 C:\...\WebSite39\
Error 2 The type or namespace name 'BinaryReader' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\SANCHANA\My Documents\Visual Studio 2008\WebSites\WebSite39\Default.aspx.cs 26 9 C:\...\WebSite39\
Error 3 The type or namespace name 'BinaryReader' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\SANCHANA\My Documents\Visual Studio 2008\WebSites\WebSite39\Default.aspx.cs 26 31 C:\...\WebSite39\
Error 4 The name 'Path' does not exist in the current context C:\Documents and Settings\SANCHANA\My Documents\Visual Studio 2008\WebSites\WebSite39\Default.aspx.cs 35 58 C:\...\WebSite39\