C# 将图像上载到文件夹MVC 5
我正在尝试将图像上载到我的project Releases文件夹中。但是它没有上传到想要的地方。即使它显示“文件上载成功”消息 控制器:C# 将图像上载到文件夹MVC 5,c#,asp.net-mvc,C#,Asp.net Mvc,我正在尝试将图像上载到我的project Releases文件夹中。但是它没有上传到想要的地方。即使它显示“文件上载成功”消息 控制器: public ActionResult UploadImages(HttpPostedFileBase photo_url) { if (photo_url != null) try { photo_url.SaveAs(Path.Combine(HttpContext.Server.MapPath
public ActionResult UploadImages(HttpPostedFileBase photo_url)
{
if (photo_url != null)
try
{
photo_url.SaveAs(Path.Combine(HttpContext.Server.MapPath("~/Images/Releases"),
photo_url.FileName));
ViewBag.Message = "File uploaded successfully";
}
catch (Exception ex)
{
ViewBag.Message = "ERROR:" + ex.Message.ToString();
}
else
{
ViewBag.Message = "You have not specified a file.";
}
return View();
}
“它没有上载到所需的位置”-那么它将上载到哪里?为什么不尝试使用调试器并找出组合路径。如果它成功上传到文件,路径必须在那里供您检查。另请参阅:也请不要将代码添加为图像。粘贴您的
视图
,方法与使用控制器时相同?!如果您在调试模式下运行,它可能会将其放在项目所在的文件夹中。这是在构建或部署到服务器时发生的吗