Код: Выделить всё
if (image.ImageFile != null)
Код: Выделить всё
{Код: Выделить всё
string result = Path.GetRandomFileName();
var r = result.Replace('.', '3');
string path = @"\\wwwroot\\images\\" + r + "\\";
string imageName = Path.GetFileName(image.ImageFile.FileName);
string folderPath = Path.Combine(_env.ContentRootPath + path);
Directory.CreateDirectory($"{folderPath}");
var filePath = Path.Combine(folderPath + imageName);
using (var stream = System.IO.File.Create(filePath))
{
image.ImageFile.CopyToAsync(stream);
}
Файл создан, но его размер 0Б
Подробнее здесь: https://stackoverflow.com/questions/793 ... vc-vs-2022
Мобильная версия