Image is not taking ...whan i press brows.. [Resolved]

Posted by Vinu under ASP.NET on 3/13/2013 | Points: 10 | Views : 1497 | Status : [Member] | Replies : 2
protected void btnview_Click(object sender, EventArgs e)
{
string imgPath;
if (picupload.HasFile)
{

picupload.SaveAs(@"D:\vinu\Master\Facpic"+picupload.FileName);
lblpic.Text = "Picture Uploaded Successfully..!!"+picupload.FileName;

imgPath=(@"D:\vinu\Master\Facpic"+picupload.FileName);
img.ImageUrl = imgPath;
img.Visible = true;


}
else
{
lblpic.Text = "No Picture Uploaded...!!";

}
}

Vinu malli


Responses

Posted by: Santhi on: 3/13/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi

Dont give the full path for the image url
Just give the folder name alone after that give your image name.

For example:
Try this code:
It works:
Design Page:
 <asp:fileupload ID="Fileupload1" runat="server"></asp:fileupload>

<asp:Button ID="Button1"
runat="server" Text="Button" onclick="Button1_Click" />
<asp:Image ID="Image1" runat="server" />


CS page:
protected void Button1_Click(object sender, EventArgs e)

{
if (Fileupload1.HasFile)
{
if (!Directory.Exists(Server.MapPath("Images")))
{
Directory.CreateDirectory(Server.MapPath("Images"));

}

Fileupload1.SaveAs(Server.MapPath("Images\\" + Fileupload1.FileName));
Image1.ImageUrl = "Images\\" + Fileupload1.FileName;
}

}


This will show you the image.

Thanks & Regards,
Santhi .V

Vinu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vinu on: 3/13/2013 [Member] Starter | Points: 25

Up
0
Down
Actualy...i got...same...ans...but..
HasFile...=== nulls...
so...not getting..

but...other wise..
my code...ans is rite...

Vinu malli

Vinu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response