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);
}
}在运行此代码时,我会收到以下错误:
‘/WebSite11 11’应用程序中的服务器错误 HTTP错误400 -坏请求。 版本信息: ASP.NET开发服务器10.0.0.0
发布于 2012-07-16 07:21:32
如果图像文件夹位于站点的根目录,那么路径应该是
string fp = Server.MapPath(~"/images");并且尝试在不同的bcz上运行这个站点,几天前我看到了同样的问题,但是当他在不同的浏览中搜索代码时,它工作得很好。
请参阅下面的文章HTTP Error 400 - Bad Request due to FileUpload control in vb.net
https://stackoverflow.com/questions/11499715
复制相似问题