ASP.NET 2.0 FileUpload

如何使用ASP.NET的檔案上傳功能(FileUpload)

protected void ButtonInsertFile_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
try
{
FileUpload1.SaveAs(@"D:\" + FileUpload1.FileName);
LabelFileNotify.Text = "File Uploaded: " + FileUpload1.FileName;
}
catch (Exception ex)
{
LabelFileNotify.Text = "File Uploaded Failed.";
}

}
else
{
LabelFileNotify.Text = "No File Uploaded.";
}
}

沒有留言:

發佈留言