文件夾權限是好的。它不會給我一個錯誤。我點擊下面這個函數的上傳按鈕,當它完成時,我上傳的文件不在那裏。有任何想法嗎?謝謝!asp.net文件上傳問題;文件沒有上傳
protected void submitFile(object sender, EventArgs e){
if(fileUpload.HasFile)
{
try
{
if(
fileUpload.PostedFile.FileName.ToLower().Substring(fileUpload.PostedFile.FileName.Length - 3) == "doc" ||
fileUpload.PostedFile.FileName.ToLower().Substring(fileUpload.PostedFile.FileName.Length - 4) == "docx")
{
if(fileUpload.PostedFile.ContentLength < 512000)
{
string filename = Path.GetFileName(fileUpload.FileName);
filename = filename.Replace(" ", "");
fileUpload.SaveAs("C:/inetpub/ ------ directory --------/Data" + filename);
StatusLabel.Text = "Upload status: File uploaded complete.";
}
else
StatusLabel.Text = "Upload status: The file has exceded the maximum file size of 500 kb. Please ensure that the file is smaller than 500 kb and try again";
}
else
StatusLabel.Text = "Upload status: Only PDF and Microsoft Word files are accepted. Please try again.";
}
catch(Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}
有史以來最好的標題? –
謝謝。我也是這麼想。對不起,我改了它。 – Bender
你是否附加了一個調試器並檢查了'SaveAs'部分是否被實際執行?或者你有什麼異常?基本上,你能否詳細說明你所嘗試過的? –