<table>
<tr>
<td class="style3">
<asp:Label ID="Label1" runat="server" Text="Photo upload" />
</td>
<td class="style4">
<asp:FileUpload runat="server" ID="PhotoUpload" />
</td>
<td class="style4">
<asp:Button runat="server" OnClick="btnPreview_Click" ID="btnPhotoPreview" Text="Preview" />
</td>
<td class="style1">
<asp:Image runat="server" ID="ImagePreview" Height="164px" Width="125px" />
</td>
</tr>
</table>
****************************************************************************************************************************
using System;
using System.Web;
public class ImageHandler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest (HttpContext context) {
//Checking whether the imagebytes session variable have anything else not doing anything
if ((context.Session["ImageBytes"]) != null)
{
byte[] image = (byte[])(context.Session["ImageBytes"]);
context.Response.ContentType = "image/JPEG";
context.Response.BinaryWrite(image);
}
}
public bool IsReusable {
get {
return false;
}
}
}
****************************************************************************************************************************
protected void btnPreview_Click(object sender, EventArgs e)
{
Session["ImageBytes"] = PhotoUpload.FileBytes;
ImagePreview.ImageUrl = "~/ImageHandler.ashx";
}
Just rewrite the code inside processrequest to get the session variable and generate the image
Reddysankark@Yahoo.Com, if this helps please login to Mark As Answer. |
Reply | Alert Moderator