如何使用C#在BLOB字段中上传/保存图像

时间:2019-07-10 08:37:03

标签: c# asp.net-mvc oracle upload blob

我需要一些帮助来指导我如何使用ASP.NET C#在Oracle的BLOB字段中上载/保存图像文件

员工模型

using System.Web;

namespace ErpScoop.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;

    [Table("SCOOP_APP.EMPLOYEE")]
    public partial class Employee
    {
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public decimal EMP_ID { get; set; }

        [StringLength(200)]
        public string EMP_FULL_NAME { get; set; }

        [Display(Name = "Change Image")]
        public byte[] EMP_PHOTO { get; set; }

    }
}

这是控制者

员工控制者

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "EMP_ID,EMP_FULL_NAME,EMP_PHOTO")] Employee employee, HttpPostedFileBase imageProfile)
    {            
        if (ModelState.IsValid)
        {              
            db.EMPLOYEEs.Add(employee);
            db.SaveChanges();
            return RedirectToAction("Index");
        }            
        return View(employee);
    }

0 个答案:

没有答案