2012-07-16 114 views
0
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 

public partial class _Default : System.Web.UI.Page 
{ 
protected void Page_Load(object sender, EventArgs e) 
{ 

} 
protected void Button1_Click(object sender, EventArgs e) 
{ 
    String fn = FileUpload1.FileName; 
    string fp = Server.MapPath("images"); 
    if (fp.EndsWith("\\") == false) 
    { 
     fp = fp + "\\"; 
    } 
    fp = fp + fn; 
    FileUpload1.PostedFile.SaveAs(fp); 
} 
} 

上捉迷藏这个代码,我收到以下错误:FileUpload控件导致服务器错误

Server Error in '/WebSite11' Application
HTTP Error 400 - Bad Request.
Version Information: ASP.NET Development Server 10.0.0.0

+0

在不同的浏览器上运行您的网站。 – 2012-07-16 07:19:21

回答

0

如果图像文件夹位于你的站点的根目录,然后路径应该是这样的

string fp = Server.MapPath(~"/images"); 

并且还尝试在几天前在另一个brwose bcz上运行该站点,但我看到了相同的问题,但是当他在不同浏览器上传递代码时,它可以正常工作。

看到下面的帖子 HTTP Error 400 - Bad Request due to FileUpload control in vb.net

相关问题