Click here to Skip to main content
Rate this: bad
good
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.8K
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
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 319
2 CPallini 275
3 DamithSL 214
4 Maciej Los 185
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
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