我在我的辦公室使用IIS 7.5在Intranet上發佈了Web應用程序。我在表單中使用了「異步文件上傳」控件。 '用戶'上傳圖片後,顯示成功消息,路徑也存儲在數據庫&'圖像'被附加並通過電子郵件發送到'管理員'根據我的C#代碼。所有工作正常,但在我的系統中沒有看到任何圖像!我檢查了我的項目文件夾,並檢查了項目文件夾'C:\ inetpub \ wwwroot \ contractor \ Upload \ Commerical certificates'的路徑。任何人都可以幫助我在我的系統中獲取圖像。 (當我在我的獨立系統中使用應用程序時,圖像可用)。在哪裏可以看到「上傳圖片」
protected void AFUCmpCertificate_UploadedComplete(
object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
try
{
if (AFU1.HasFile)
{
String fileExt = System.IO.Path.GetExtension(AFU1.FileName);
if (fileExt == ".pdf" || fileExt == ".jpg" || fileExt == ".gif"
|| fileExt == ".bmp" || fileExt == ".jpeg" || fileExt == ".png" || fileExt == ".tif")
{
if (AFU1.PostedFile.ContentLength < 2048000)
{
string filename = System.IO.Path.GetFileName(AFU1.FileName);
AFU1.SaveAs(Server.MapPath("~/Upload/Commerical Certificates/")
+ lblBasicVendorID.Text + filename);
lblCommStatus.Text = "File uploaded";
}
else
{
lblCommStatus.Text = "The file type not accepted or more than 2MB";
}
}
}
}
catch (Exception ex)
{
lblCommStatus.Text = "The file could not be upload.";
}
}
是'C:\ inetpub \ wwwroot \ contractor \ Upload \ Commerical certificates'這個應用程序運行的Web服務器或本地機器上的路徑嗎? – simonlchilds
只是調試,看看'Server.MapPath(「〜/ Upload/Commerical Certificates /」)的價值是什麼' –
@simonlchilds:我的本地機器的路徑。我在其中創建了文件夾'Upload'和'Commerical Certificates'。 – Hari