Hi friends.
I am developing an web application. here i am using file uploader and i am uploading images.
Problem here is, i need to provide preview of uploaded image as soon as file is uploaded.
How can i do this.
Regards
Rajath
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
ShankeyRank #972 · 2.1K reputationPosted Aug 27, 2010, 6:40 AM EDT
Hi rajath r,
Following is your solution ,
But don't forget to mark my answer as accepted if it helped you :)
And if you want to upload .gif file then change folllowing condition
if (Extension == "jpg" || Extension == "JPG" || Extension == "JPEG" || Extension == "jpeg")
Aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
C# code
using System;
using System.Collections;
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 Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fileUploadImage.FileName != "")
{
String fullpath = Server.MapPath(fileUploadImage.FileName);
fileUploadImage.SaveAs(fullpath);
imgShow.ImageUrl = fileUploadImage.FileName;
}
}
}
Manikavelu VelayuthamRank #413 · 6K reputationPosted Aug 27, 2010, 2:59 AM EDT
just put a preview button over there, through that just hide and show the image. you should dynamically change the image url, so that the uploaded image will be get previewed.
Mark this post as answered, if this really helps you.