【发布时间】:2019-04-10 06:31:37
【问题描述】:
我正在尝试使用croppie将图像裁剪到数据库的文件夹和图像路径后保存图像,但它转换为base64并且我也不知道如何将此数据发送到控制器以及如何将图像保存到文件夹中&它到数据库的路径。
我已经尝试保存file.write函数但它没有将图像数据发送回控制器
public ActionResult AddProduct(Tbl_Product product,HttpPostedFileBase file_photo)
{
string name = null;
string ext = null;
if (ModelState.IsValid==true)
{
if (file_photo != null)
{
name = Path.GetFileNameWithoutExtension(file_photo.FileName);
ext = Path.GetExtension(file_photo.FileName);
string path = Path.Combine(Server.MapPath("~/ProductImages"), name + ext);
file_photo.SaveAs(path);
}
product.ProductImage = name + ext;
product.CreatedDate = DateTime.Now;
_unitofwork.GetRepositoryInstance<Tbl_Product>().Add(product);
return RedirectToAction("Product");
}
else
{
ViewBag.CategoryList = GetCategory();
return View();
}
}
我想将图像保存在文件夹和数据库路径中,但它显示 base64 图像
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-5 croppie