htmlinputfile.aspx 662 B

12345678910111213141516171819202122232425262728
  1. <%@ Page Language="C#" %>
  2. <html>
  3. <script runat=server>
  4. void Page_Load ()
  5. {
  6. if (!IsPostBack)
  7. return;
  8. HttpFileCollection Files = Request.Files;
  9. string [] names = Files.AllKeys;
  10. for (int i = 0; i < names.Length; i++) {
  11. Files [i].SaveAs ("FILE" + i);
  12. }
  13. }
  14. </script>
  15. <title>HtmlInputFile</title>
  16. <body>
  17. This should save the file you upload in the server as 'FILE0'. <br/>
  18. <form id="myForm" name="myform" method="post" runat="server">
  19. Pick a file:
  20. <input id="myFile" type="file" runat="server">
  21. <br>
  22. <asp:Button id="btn" Text="Go send it!" runat="server" />
  23. <asp:TextBox Columns="2" MaxLength="3" Text="1" runat="server"/>
  24. </form>
  25. </body>
  26. </html>