将图像上传到文件夹MVC 5

时间:2018-05-25 13:39:14

标签: c# asp.net-mvc

我正在尝试在我的项目Releases文件夹中上传图片。但它不是在所需的位置上传。即使它显示"文件已成功上传"消息。

  

image

控制器:

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(); 
}

0 个答案:

没有答案