In the form, enctype = "multipart/form-Data" indicates the mime encoding of the form. By default, the encoding format of enctype is application/X-WWW-form-urlencoded, which cannot be used for file upload. Only multipart/form-data can be used to completely transmit file data, perform the following operations.
Example of using a form to upload a file:
<Form ID = "form1" runat = "server"Enctype = "multipart/form-Data">
<Div>
<A id = "addattach" href = "#"> Add an uploaded file </a>
<Div id = "Files">
<Input type = "file" name = "f1"/>
<Input type = "file" name = "F2"/>
</Div>
<Asp: button id = "btnsend" runat = "server" text = "send" onclick = "btnsend_click"/>
</Div>
</Form>
Protected void btnsend_click (Object sender, eventargs E)
{
For (INT I = 0; I <
Request. Files. Count; I ++)
{
If (! String. isnullorempty (Request. Files [I]. filename))
{
Request. Files [I]. saveas
(Path. Combine (server. mappath ("Files"), path. getfilename (request. Files
[I]. filename )));
}
}
}