[HttpPost] public IActionResult OnPostMyUploader(IFormFile MyUploader, string empUsername) { // No point loading and resizing the image if we're not going to use it: if (MyUploader is null) return new ObjectResult(new { status = "fail" }); string uploadsFolder = @"\\10.10.10.67\AQSImages\IdPictures\"; string userfileName = empUsername.ToString() + ".jpg"; string filePath = Path.Combine(uploadsFolder, userfileName); using var fileStream = new FileStream(filePath, FileMode.Create); using var image = System.Drawing.Image.FromStream(MyUploader.OpenReadStream()); using var resized = new Bitmap(image, new System.Drawing.Size(150, 150)); using var imageStream = new MemoryStream(); resized.Save(imageStream, ImageFormat.Jpeg); imageStream.Seek(0L, SeekOrigin.Begin); imageStream.CopyTo(fileStream); return new ObjectResult(new { status = "success" }); }
<div class="col-4"> <label class="w-100">Username</label> <input id="empUsername" class="input-form w-100" disabled> </div>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)