HttpPostedFile:找不到文件

string strOfId = Request["ofid"];
string strTId = Request["tid"];
string strOrId = Request["orid"];
HttpPostedFile hpfUpload = fileUp.PostedFile;
FileInfo fiFile = new FileInfo(hpfUpload.FileName);
string strExt = new FileInfo(hpfUpload.FileName).Extension.ToLower();
if (fiFile.Length > 3 * 1024 * 1024)
strTxt = "失败:上传的文件必须小于3MB。";
else if (strExt == ".jpg" || strExt == ".bmp" || strExt == ".gif")
{
//为图像命名
string strSaveName = "MimaBaohuka/" + strOfId + strExt;
if (File.Exists(Server.MapPath("~/" + strSaveName)))
File.Delete(Server.MapPath("~/" + strSaveName));
hpfUpload.SaveAs(Server.MapPath("~/" + strSaveName));

//将图像链接写入数据库
SqlConnection scConn = new SqlConnection();
scConn.ConnectionString = "Data Source=(local); Initial Catalog=aa; Integrated Security=True";
scConn.Open();
SqlCommand scUpdate = new SqlCommand();
scUpdate.CommandText = "update task set t_mbk='" + strSaveName + "' where t_id=" + strTId;
scUpdate.Connection = scConn;
if (scUpdate.ExecuteNonQuery() == 1)
{
strTxt = "<br/>上传成功! 点击图像可以查看原图。<br/><br/><a target=\"_blank\" href=\"" + strSaveName + "\"><img border=\"0\" alt=\"\" width=\"200px\" height=\"200px\" src=\"" + strSaveName + "\"/></a>";
strTxt += "<br/><br/><a target=\"_top\" href=\"jdchx.aspx?ofid=" + strOfId + "&orid=" + strOrId + "\">查看订单</a>";
}
else
strTxt = "<br/>上传失败,请重新上传。";
scConn.Close();
scConn.Dispose();
scUpdate.Dispose();
}
else
strTxt = "失败:上传的文件只支持以下格式:jpg、bmp、gif。";
}
else
Response.Redirect("HtmlFiles/Error/Error.html");

服务器上测试没问题,其它电脑上测试全是一个错误:找不到文件。可是文件明明在那儿好好的,ASP.NET权限都给到与管理员齐平,它还是找不到文件,请问这是怎么回事?
其它代码没有影响。我复制的时候多复制了一点。代码没有报错或警告。

为你的MimaBaohuka文件夹赋予可写权限
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网