开发者

display an image [closed]

开发者 https://www.devze.com 2023-02-10 14:06 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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