<div>
<EjsUploader Id="UploadFiles">
<UploaderAsyncSettings SaveUrl="api/SampleData/Save" RemoveUrl="api/SampleData/Remove"></UploaderAsyncSettings>
</EjsUploader>
</div> |
[HttpPost("[action]")]
public IActionResult Save(IList<IFormFile> UploadFiles)
{
IFormFile uploadedImage = UploadFiles.FirstOrDefault();
if (uploadedImage.ContentType.ToLower().StartsWith("image/"))
// Check whether the selected file is image
{
byte[] b;
using (BinaryReader br = newBinaryReader(uploadedImage.OpenReadStream()))
{
b = br.ReadBytes((int)uploadedImage.OpenReadStream().Length);
// Convert the image in to bytes
}
Response.StatusCode = 200;
}
return Content("");
} |