0
我想提出一個註冊頁面,同時使用的輸入標籤上傳用戶的圖像,它正在運行的網站同時給出錯誤:「的NullReferenceException是unhandledby用戶代碼」。請幫我解決這個問題。這是給錯誤的方法是:的NullReferenceException是unhandledby用戶代碼
protected void Button2_Click(object sender, EventArgs e)
{
var path = "Memberimg";
string fn = System.IO.Path.GetFileName(f1.PostedFile.FileName);
string SaveLocation = Server.MapPath("Memberimg") + "\\" + fn;
if ((f1.PostedFile != null) && (f1.PostedFile.ContentLength > 0))
{
try
{
f1.PostedFile.SaveAs(SaveLocation);
Response.Write("The file has been uploaded.");
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
}
else
{
Response.Write("Please select a file to upload.");
}
}