Páginas

terça-feira, 15 de outubro de 2013

Upload - netframework 4.5

Upload - netframework 4.5

       <h4>Selecione um arquivo:</h4>
        <asp:FileUpload id="FileUpload1"  runat="server">
        </asp:FileUpload>
        <asp:Button id="UploadBtn" 
            Text="Upload Arquivo"
            runat="server" OnClick="UploadBtn_Click" >
        </asp:Button>    
        <asp:Label ID="Label_resultado" runat="server" Text="Label"></asp:Label>
        <hr />
 
 
 
   protected void UploadBtn_Click(object sender, EventArgs e)
    {
        string savePath = HttpContext.Current.Server.MapPath("~/arquivos/matos/");
        if (FileUpload1.HasFile)
        {
            string fileName = Server.HtmlEncode(FileUpload1.FileName);
            savePath += fileName;
            FileUpload1.SaveAs(savePath);
            Label1.Text = "Your file was uploaded successfully.";
        } 
 
 
 

Nenhum comentário:

Postar um comentário