При сохранении двоичных данных в таблицу я получаю NULL - PullRequest
0 голосов
/ 04 января 2019

Здесь я пытаюсь загрузить файл в базу данных, но я получаю NULL в моей базе данных
Пожалуйста, дайте мне любую подсказку.

var httpRequest = HttpContext.Current.Request;
var httpPostedFile = HttpContext.Current.Request.Files["file"];

foreach(string file in httpRequest.Files) 
{
    var postedfile = httpRequest.Files[file];
    var FileName = httpPostedFile.FileName;
    int fileSize = httpPostedFile.ContentLength;
    byte[] fileByteArray = new byte[fileSize];
    httpPostedFile.InputStream.Read(fileByteArray, 0, fileSize);
    HttpPostedFile postedFile = HttpContext.Current.Request.Files[file];
    byte[] bytes;

    using(BinaryReader br = new BinaryReader(postedFile.InputStream)) 
    {
        bytes = br.ReadBytes(postedFile.ContentLength);
    }
    Temp_Table = new Temp_Table {
        Profiledata = bytes
    };
    db.Table.Add(_temp);
    db.SaveChanges();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...