<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td><asp:Label id="lblselectfile" Text="Select File" runat="server"></asp:Label></td> <td><asp:FileUpload ID="filupload1" runat="server" /></td> </tr> <tr> <td><asp:Button ID="btnsubmit" Text="Submit" runat="server" onclick="btnsubmit_Click" /></td> <td><asp:Label ID="lbldisplay" runat="server"></asp:Label></td> </tr> <tr> <td><asp:HyperLink ID="hyperlink1" Text="color" runat="server" NavigateUrl="~/Color.docx"></asp:HyperLink></td> <td><asp:HyperLink ID="hyperlink2" Text="Sql commands n joins " runat="server" NavigateUrl="~/Sql commands n joins.docx"></asp:HyperLink></td> <td><asp:HyperLink ID="hyperlink3" Text="3rd Transaction" NavigateUrl="~/3rd transaction.xlsx" runat="server"></asp:HyperLink></td> </tr> </table> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnsubmit_Click(object sender, EventArgs e) { string FilePath = ""; string[] a = new string[1]; string FileName = ""; if (filupload1.FileName.Length > 0) { FileName = filupload1.FileName; FilePath = Server.MapPath(@"~\Files"); try { filupload1.SaveAs(FilePath + @"\" + FileName); } catch { File.Delete(FilePath + @"\" + FileName); filupload1.SaveAs(FilePath + @"\" + FileName); } lbldisplay.Text = "Uploaded successfully"; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)