开发者

display an image [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

how to browse an image location u开发者_开发百科sing fileupload and display it into an image control


Try this:

In your asp.net page:

<form id="form1" runat="server">
<div>
    <asp:Image ID="uploadedImage" runat="server" />
    <asp:FileUpload ID="fileUploadControl" runat="server" />
    <asp:Button ID="btnSubmit" runat="server" Text="submit" />
</div>
</form>

And in its code behind:

protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack)
    {
        if (fileUploadControl.HasFile)
        {
            string location = "Images/imageName.png";
            fileUploadControl.SaveAs(Server.MapPath("~/" + location));
            uploadedImage.ImageUrl = location;
        }
    }
}

The code is not perfect. But it gives you a hint...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜