HTML Controls ASP.Net Tutorial

<%@ Page language="C#"%>
<%@ Import Namespace="System.IO" %>

    void UploadButton_Click(object sender, EventArgs e)
    {
        string savePath = @"c:\";
        if (!Directory.Exists(savePath)) {
          string msg = "

The upload path doesn't exist: {0}

";
            Response.Write(String.Format(msg, savePath));
            Response.End();
        }
        if (FileUpload1.PostedFile != null)
        {
            string fileName = Path.GetFileName(FileUpload1.Value);
            savePath += fileName;
          FileUpload1.PostedFile.SaveAs(savePath);
            UploadStatusLabel.InnerText = "File saved as: " + savePath + "";
        }
        else
        {
            UploadStatusLabel.InnerText = "You did not specify a file to upload.";
        }
    }



    HtmlInputFile


    
        
          

Select a picture to upload:


            
            Picture to upload
            
            
                            onserverclick="UploadButton_Click" />