Click here to Skip to main content
12,070,171 members (29,467 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET Windows .NET image , +
i selected image using file upload control....but i'm getting stuck on how to show in image box...
my code is:

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 21-Feb-13 1:31am
Deenuji3.9K
Edited 21-Feb-13 1:47am
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

get the full path file u had uploaded and then pass it into the imageurl you will get the image
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

After the below line,
savePath += fileName;
the path of image becomes as savePath

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

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web04 | 2.8.160208.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100