How I can upload Image File via ASP.NET Web API?
I have an input tag in File mode and it posted to API, how I can save it to server folder?
I tried th
If your API only allows one image at a time, System.Web.Helpers.WebImage
may help. Just make sure that a filename is included.
------WebKitFormBoundaryzrmNUJnUirtKajVF Content-Disposition: form-data; name="image"; filename="IMG_3321.JPG" Content-Type: image/jpeg
------WebKitFormBoundaryzrmNUJnUirtKajVF--
[HttpPost]
[ResponseType(typeof(Models.Photo))]
[Route("upload")]
public async Task Upload()
{
var img = WebImage.GetImageFromRequest();
if (img == null)
{
return BadRequest("Image is null.");
}
// Do whatever you want with the image (resize, save, ...)
// In this case, I save the image to a cloud storage and
// create a DB record to reference the image.
}