Reputation: 41
net and am just wondering if there is a method for the file upload tag in a library anywhere ?
Thanks guys heres my code
<asp:FileUpload ID="FileUpload1" runat="server" ForeColor="white" />
Upvotes: 1
Views: 609
Reputation: 176896
You and put one Upload Button and on click event of that button write code as below will do your task
Aspx page code
<asp:FileUpload ID="fpManualCostActual" runat="server" />
<asp:LinkButton ID="btnUpload" runat="server" OnClick="btnUpload_Click"
Upload</asp:LinkButton>
Cs file code
protected void btnUpload_Click(object sender, EventArgs e)
{
try
{
if (fpManualCostActual.HasFile)
{
string filePath = Server.MapPath("~/Upload/" +
SessionManager.UID.ToString() + "/MonthlyActual" +
DateTime.Now.ToString("MMddyyyyHHmmss") + fileExt);
fpManualCostActual.SaveAs(filePath);
}
}
catch (Exception ex)
{
CustomException(ex, CommonHelper.ExceptionType.DBExceptionPolicy);
}
}
Upvotes: 1