【发布时间】:2013-04-05 12:20:26
【问题描述】:
我正在尝试将图像存储到两个应用程序中(均发布在服务器上)。这是我保存图像的代码:
string path = Server.MapPath("/Images/Landing/bottom_banner/");
string path1 = @"_http://10.241.193.22/Myapplication/Images/Landing/bottom_banner/";
HttpPostedFileBase photo = Request.Files["adup"];
if (photo.ContentLength != 0)
{
string lastPart = photo.FileName.Split('\\').Last();
Random random = new Random();
int rno = random.Next(0, 1000);
photo.SaveAs(path + rno + lastPart);
photo.SaveAs(path1 + rno + lastPart);
}
注意:Myapplication 是托管在同一服务器上的另一个应用程序
我的问题是我可以使用Server.MapPath 将图像保存在我的第一个应用程序中,但是当编译器进入photo.SaveAs(path1 + rno + lastPart) 部分时会出现错误:
SaveAs方法配置为需要root路径,路径'_http://10.241.193.22/Myapplication/Images/Landing/bottom_banner/676Chrysanthemum.jpg'没有root
请建议我怎样才能消除这个问题?
【问题讨论】:
-
在那个问题中,这个人试图将文件保存在一个应用程序中。这里我试图保存到两个单独的应用程序中。
-
尽管如此,第一个答案中给出了解决方案,请尝试将其用于您的案例
标签: c# asp.net-mvc save-as server.mappath