HOSTED CODE ONLY
if (!IsPostBack)
{
FileUpload1.Attributes["onchange"] = "UploadFile(this)";
}
if (!IsPostBack)
{
FileUpload1.Attributes["onchange"] = "UploadFile(this)";
}
protected void Upload(object sender, EventArgs e)
{
FileUpload1.SaveAs(Server.MapPath(@"~/Admin/") + "//member//" + FileUpload1.FileName);
Label1.Text = FileUpload1.FileName;
Image1.ImageUrl = "/Admin/member/" + Label1.Text;
}
ASPX CODE
<HEAD>
<script type="text/javascript">
function UploadFile(fileUpload) {
if (fileUpload.value != '') {
document.getElementById("<%=btnUpload.ClientID %>").click();
}
}
</script>
</HEAD>
<asp:FileUpload ID="FileUpload1" runat="server"/><br />
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="Upload" Style="display: none" />
No comments:
Post a Comment