Save below as an .aspx file in IIS.
<%@ Page Language="C#" AutoEventWireup="true" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Test Upload file</title> </head> <body> <form id="form1" runat="server" enctype="multipart/form-data"> <input type="file" id="myFile" name="myFile" /> <asp:Button runat="server"
ID="btnUpload" OnClick="btnUploadClick" Text="Upload" />
</form> <script runat=server> protected void btnUploadClick(object sender, EventArgs e) { HttpPostedFile file = Request.Files["myFile"]; //check file was submitted if (file != null && file.ContentLength > 0) { string fname = System.IO.Path.GetFileName(file.FileName); file.SaveAs((System.IO.Path.Combine("C:/Temp/", fname))); } } </script> </body> </html>
No comments:
Post a Comment