0
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.Master"
CodeBehind="Mortgageclient.aspx.cs" Inherits="MortgageSaver._Default" %>
protected void btnfupload_Click(object sender, EventArgs e)
{
try
{
if (FileUpload1.HasFile)
{
if (!Directory.Exists(Server.MapPath("Documents")))
{
Directory.CreateDirectory(MapPath("Documents"));
}
string docment = FileUpload1.PostedFile.FileName;
string path = System.IO.Path.GetFileName(docment);
FileUpload1.PostedFile.SaveAs(Server.MapPath("Documents/") + path);
lblstatus.ForeColor = System.Drawing.Color.Red;
lblstatus.Text = "Selected File has been Uploaded...";
}
}
catch
{
lblstatus.ForeColor = System.Drawing.Color.Red;
lblstatus.Text = "Selected File has not been Uploaded...";
}
}
這是我的代碼來上傳文件,但它從對話框中選擇一個文件,但是當我點擊UploadFile按鈕時,它顯示「選定的文件尚未上傳。」,如果我可以單獨運行此頁,我是工作,但我在tabpanel中使用它,因此在這種情況下,它不工作。如何使用fileupload Control將文件上傳到aspx頁面?
您是否嘗試過實際捕捉異常以查看異常? – David
實際上,在這裏我沒有收到任何異常,但是當我通過在(FileUpload1.HasFile)處保留斷點來檢查它時,它沒有進入if循環來檢查,所以這個文件並不接受。 – tiru