Last post Jul 10, 2020 10:46 AM by mgebhard
Jul 10, 2020 09:43 AMfirstname.lastname@example.org|LINK
I've implemented this code to save images at my core 2.1 mvc project:
Saving images was done successfully but suddenly it returns this error:
ArgumentNullException: Value cannot be null. Parameter name: encoder
I searched about it and found there is a solution by specifying the type of the image: (ImageExtensions.cs)
public static byte ToByteArray(this Image current)
using (var stream = new MemoryStream())
//current.Save(stream, current.RawFormat); Not Working
current.Save(stream, ImageFormat.Jpeg); // Working but will convert the type to Jpeg.
How to let the first one works (RawFormat) which take the format of the image please?
Jul 10, 2020 10:46 AM|mgebhard|LINK
The official ASP.NET Core documentation explains how to upload and save a file of any type.