KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using asp.net mvc 4 webapi beta to build a rest service. I need to be able to accept POSTed images/files from client applications. Is this possible using the webapi? Below is how action I am currently using. Does anyone know of an example how this should work? [HttpPost] public string ProfileImagePost(HttpPostedFile profileImage) { string[] extensions = { ".jpg", ".jpeg", ".gif", ".bmp", ".png" }; if (!extensions.Any(x => x.Equals(Path.GetExtension(profileImage.FileName.ToLower()), StringComparison.OrdinalIgnoreCase))) { throw new HttpResponseException("Invalid file type.", HttpStatusCode.BadRequest); } // Other code goes here return "/path/to/image.png"; }
Tags (comma-separated)
Save Edits
Cancel