我用的ewebeditor的文本编辑器,在我本机上传图片没问题,可是把站点挪到服务器就不能上传了?
这是ewebeditor保存图片的代码,请大侠们帮忙解决解决。
/// <summary>
/// 保存文件
/// </summary>
/// <param name="UpLoadPath">路径</param>
/// <param name="FileType">文件类型</param>
private void SaveAs(string UpLoadPath,string FileType)
{
bool UpFileOk = false;
string[] AllowFileExtensions = null;
if (FileUpload1.HasFile)
{
string currectFileExtension = Path.GetExtension(FileUpload1.FileName).ToLower();
AllowFileExtensions = GetConfigInfo(FileType, "config.config").Split('|');
for (int i = 0; i < AllowFileExtensions.Length; i++)
{
if (currectFileExtension == AllowFileExtensions[i].ToLower())
{
UpFileOk = true;
break;
}
}
}
if (UpFileOk)
{
if (Directory.Exists(Server.MapPath(UpLoadPath)))
{
try
{
FileUpload1.SaveAs(Server.MapPath(UpLoadPath + FileUpload1.FileName));
InsertFilePath.Value = Request.Path.Substring(0, Request.Path.LastIndexOf("/")+1) + UpLoadPath + FileUpload1.FileName;
uploadPanel.Visible = false;
resultPanel.Visible = true;
}
catch
{
Response.Redirect("Error.htm");
}
}
else
{
try
{
Directory.CreateDirectory(Server.MapPath(UpLoadPath));
FileUpload1.SaveAs(Server.MapPath(UpLoadPath + FileUpload1.FileName));
InsertFilePath.Value = Request.Path.Substring(0, Request.Path.LastIndexOf("/")+1) + UpLoadPath + FileUpload1.FileName;
uploadPanel.Visible = false;
resultPanel.Visible = true;
}
catch
{
Response.Redirect("Error.htm");
}
}
}
else
{
Response.Write("<script>alert('格式不正确');history.back(-1)</script>");
}
}
在本地都会提示上传成功,可是在服务器就提示上传失败。会跳到Error.htm,怎么回事啊?