- In your api post method, you need to verify that the request contains files, via Request.Content.IsMimeMultipartContent
- Go through the files attached to the request, using HttpContext.Request.Files, casting them to HttpPostedFileBase.
- Now you do what you want with the files.
To test this using a http client like google's Advanced REST Client, simply mark the request as a post method, and you will be able to click a "Files" option, like the in the image below:
Usage:
try { if (Request.Content.IsMimeMultipartContent()) { HttpFileCollectionBase files = this.UmbracoContext.HttpContext.Request.Files; foreach (String uploadedFileName in files) { HttpPostedFileBase httpPostedFileBase = files[uploadedFileName] as HttpPostedFileBase; /* do what you want with the file, here */ } } } catch (Exception ex) { throw ex; }
Please post how to retrieve image by using web api from angularJS
ReplyDeleteSorry, at this point I am not yet familiar with Angular, will not be able to help. I believe Stackoverflow will be of help.
ReplyDeleteI have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteASP.NET MVC Training in Chennai
ASP.NET MVC Online Training | Online LINQ Training