Click here to Skip to main content
15,914,014 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
How can i upload files by using asp.net?
Posted
Comments
Kenneth Haugland 18-Jul-12 6:04am    
To what? FTP server, webpage, please specify your question

1 solution

I assume you want to prompt the user to upload a file.

The server side form must include:

HTML
ENCTYPE="Multipart/Form-Data"


Now, we need to create the HtmlInputFile class instance,

ASP.NET
<input type="file" id="ID"  runat="server" />


ASP.NET
<![CDATA[<%-- The Web Form with the EncType property set to Multipart/Form-Data --%>
<form method="Post" enctype="Multipart/Form-Data"  runat="server">

   <%-- The File upload Html control --%>
   Choose Your File  To Upload <br>
   <input id="MyFile" type="File"  runat="server">
   <br>

   <%-- A button - when clicked the form is submitted and the
            Upload_Click event handler is fired... --%>
   <input type="Submit" value="Upload">
             OnServerClick="Upload_Click" RunAt="Server">

   ...
</input></br></input></br></form>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900