Cómo subir un archivo al servidor usando ASP.NET

Para subir un archivo al servidor mediante una aplicación web ASP.NET 2, usa el siguiente código:

ASP:
  1. <asp:FileUpload ID="FileUpload1" runat="server" /><br />
  2. <asp:Button ID="Subir" runat="server" Text="Subir foto" />

VB.NET:
  1. If FileUpload1.HasFile Then
  2.    FileUpload1.SaveAs("c:\miruta\" & FileUpload1.Filename)
  3. End If

Asegúrate de que el fólder en el que vas a grabar tus archivos tenga permisos de escritura por parte del usuario ASPNET y/o NETWORK SERVICE.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.