Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Read Bytes in Core

$
0
0

Hi,

Below uploads a physical file using Core, but how can I Read the bytes that is saved to db?

[HttpPost]public IActionResult UploadFiles()
{    long size = 0;    var files = Request.Form.Files;    foreach (var file in files)    {        var filename = ContentDispositionHeaderValue                        .Parse(file.ContentDisposition)                        .FileName                        .Trim('"');                        filename = hostingEnv.WebRootPath + $@"\{filename}";        size += file.Length;        using (FileStream fs = System.IO.File.Create(filename))        {            file.CopyTo(fs);            fs.Flush();        }    }    string message = $"{files.Count} file(s) / {size} bytes uploaded successfully!";    return Json(message);
}

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>