Create a web project. Take the two files I pasted below to overwrite the files with the same name.
In webform1.aspx, <> already replaced with <>. Replace it with another one.
Webform1.aspx
<% @ Page Language = "C #" codebehind = "webform1.aspx. cs" autoeventwireup = "false" inherits = "webapplication3.webform1" %>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> webform1 </title>
<Meta name = "generator" content = "Microsoft Visual Studio. NET 7.1">
<Meta name = "code_language" content = "C #">
<Meta name = "vs_defaultclientscript" content = "JavaScript">
<Meta name = "vs_targetschema" content = "http://schemas.microsoft.com/intellisense/ie5">
</Head>
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<Font face = ""> </font> <input id = "file1" style = "Z-INDEX: 101; left: 8px; position: absolute; top: 8px "type =" file"
Name = "file1" runat = "server">
<Asp: Label id = "label1" style = "Z-INDEX: 102; left: 16px; position: absolute; top: 40px" runat = "server"> label </ASP: label>
<Input style = "Z-INDEX: 103; left: 256px; position: absolute; top: 8px" type = "Submit" value = "Submit">
<Asp: Image id = "image1" style = "Z-INDEX: 104; left: 32px; position: absolute; top: 88px" runat = "server"> </ASP: Image>
</Form>
</Font>
</Body>
</Html>
Webform1.aspx. CS
Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Namespace webapplication3
{
///
/// Summary description for webform1.
///
Public class webform1: system. Web. UI. Page
{
Protected system. Web. UI. webcontrols. Label label1;
Protected system. Web. UI. webcontrols. Image image1;
Protected system. Web. UI. htmlcontrols. htmlinputfile file1;
Private void page_load (Object sender, system. eventargs E)
{
If (this. ispostback ){
Try
{
String filename = server. mappath ("./") + "uploadfiles/" + guid. newguid (). tostring ();
This. file1.postedfile. saveas (filename );
This. label1.text = filename;
This. image1.imageurl = filename;
}
Catch (exception ee)
{
This. label1.text = ee. message;
}
}
}
# Region web form designer generated code
Override protected void oninit (eventargs E)
{
//
// Codegen: This call is required by the ASP. NET web form designer.
//
Initializecomponent ();
Base. oninit (E );
}
///
/// Required method for designer support-do not modify
/// The contents of this method with the code editor.
///
Private void initializecomponent ()
{
This. Load + = new system. eventhandler (this. page_load );
}
# Endregion
}
}