3
如何获取上传图像(IFormFile
)的文件流并调整其大小?ASP.NET核心图像上传和调整
public ActionResult Upload(IFormFile file)
{
using (var reader = new StreamReader(file.OpenReadStream()))
{
var fileContent = reader.ReadToEnd();
var parsedContentDisposition = ContentDispositionHeaderValue.Parse(file.ContentDisposition);
//scale image here?
}
}
这将工作,如果它的目标是完整的框架,而不仅仅是核心。我可能是错的,但我认为还没有办法在核心中操纵图像。 http://www.hanselman.com/blog/RFCServersideImageAndGraphicsProcessingWithNETCoreAndASPNET5.aspx(有足够的东西遗漏给我,因为这样的原因我瞄准了4.6库)。 –
asp.net-core和asp.net 5暂时是在stackoverflow上的临时同义词;不过,为了清楚起见,我会更新标签以包含asp.net。我正在谈论完整的框架(4.6和核心)。谢谢! –
有道理。 ;-) –