<% -- <Br>
Upload. aspx <br>
This is an upload file, from which we can see the advantages of asp.net, the previously required controls to complete the program, now only a few lines of code can be easily completed. <Br>
-- %> <Br>
<% @ Import Namespace = "System. IO" %> <br>
<% @ Page Language = "C #" debug = "true" codepage = "936" %> <br>
<Br>
<Html> <br>
<Head> <br>
<Title> file upload, aspcool.com </title> <br>
<Script language = "C #" runat = "server"> <br>
<Br>
Public void UploadFile (object sender, EventArgs E) <br>
{<Br>
<Br>
If (myFile. PostedFile! = Null) <br>
{<Br>
// Define some variables <br>
String nam = myFile. PostedFile. FileName; <br>
Int I = nam. LastIndexOf ("\"); <br>
String newnm = nam. Substring (I); <br>
<Br>
<Br>
// Change the following "c: \" to the address you want to save. <Br>
MyFile. PostedFile. SaveAs ("c: \" + newnm); <br>
<Br>
// Obtain the attributes of the uploaded file. <Br>
Fname. Text = myFile. PostedFile. FileName; <br>
Fenc. Text = myFile. PostedFile. ContentType; <br>
Fsize. Text = myFile. PostedFile. ContentLength. ToString (); <br>
<Br>
<Br>
} <Br>
} <Br>
<Br>
</Script> <br>
</Head> <br>
<Body> <br>
<Center> <br>
<H3> File Upload demonstration, flying e production <Form id = "uploderform" method = "post" action = "upload. aspx" enctype = "multipart/form-data" runat = "server"> <br>
<Br>
<Table border = "1" cellspacing = "0" cellpadding = "0"> <br>
<Tr> <td> <Tr> <td> <br>
<Input type = "file" id = "myFile" runat = "server"> <br>
</Td> </tr> <br>
<Tr> <td> <br>
<Input type = "button" value = "Upload" OnServerClick = "UploadFile" runat = "server"> <br>
</Td> </tr> <br>
</Table> <br>
</Form> <br>
<Br>
<Br>
<Table border = "1" cellspacing = "0"> <br>
<Tr> <td> <B> documents </B> </td> <br>
<Td> </td> <br>
</Tr> <br>
<Tr> <br>
<Td> file name: </td> <br>
<Td> <asp: label id = "fname" text = "" runat = "server"/> </td> </tr> <br>
<Tr> <br>
<Td> file type: </td> <br>
<Td> <asp: label id = "fenc" runat = "server"/> </td> </tr> <br>
<Tr> <br>
<Td> file size: (in bytes) </td> <br>
<Td> <asp: label id = "fsize" runat = "server"/> </td> </tr> <br>
</Table> <br>
<Br>
<Br>
<Br>
<H5> you can download this program from <a href = "http://www.aspcool.com/download"> http://www.aspcool.com/download </a>. We will provide you with more programs. If you have any comments please go to my <a href = "http://www.chaxiu.com/club/right.php? Boardid = 7 & page = 1 "> ASP Forum </a>. </H5> <br>
</Center> <br>
</Body> <br>
</Html> <br>