首先,这是我的代码:
private Shoe ProcessForm(Shoe shoe, HttpPostedFileBase image)
{
try
{
shoe.Slug = CMSHelper.SanitizeTitle(shoe.Name);
shoe.LastModification = DateTime.Now;
if ((image != null) && (image.ContentLength > 0))
{
string fileName = String.Concat(shoe.ShoeId, Path.GetExtension(image.FileName));
shoe.Image = fileName;
string filePath = Path.Combine(Server.MapPath(shoe.ImagePath), fileName);
image.SaveAs(filePath);
}
}
catch (Exception e)
{
throw e;
}
return shoe;
}
在本地,此代码工作正常。目录的权限很好。它之前在其他服务器上随机运行过(我在测试 VPS 提供商时在 4 或 5 台不同的服务器上测试了此代码)。
但是,如果我尝试从家用计算机运行它,一切正常,数据库中保存了一个文件名,但没有上传任何文件。而且没有例外!!!
我一直在尝试解决这个问题将近三天和这么多无用的时间,请帮助我......我只是不明白这有什么问题......