Click here to Skip to main content
15,867,771 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i selected image using file upload control....but i'm getting stuck on how to show in image box...
my code is:

C#
if (FileUpload1.HasFile)
{
    string f2 = "df.jpg";
    String fileName = FileUpload1.FileName;
    savePath += fileName;
    FileUpload1.SaveAs(savePath);
    Label1.Text = "Your file was saved as " + fileName;
    Image1.ImageUrl = filename;
    Image1.Visible = true;

    if (fileName == f2)
    {
        Response.Write("<script>alert('Authentication Success')</script>");
    }
    else
    {
        Response.Write("<script>alert('Authentication Failed')</script>");
    }
}
else
{
    Label1.Text = "You did not specify a file to upload.";
}
Posted
Updated 21-Feb-13 0:47am
v2

get the full path file u had uploaded and then pass it into the imageurl you will get the image
 
Share this answer
 
After the below line,
C#
savePath += fileName;

the path of image becomes as savePath

So, you need to use this path to assign it to image control like below.
C#
Image1.ImageUrl = Server.MapPath(savePath);


Or else find the relative path of this path and assign to ImageUrl.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900