Skip to content

Instantly share code, notes, and snippets.

@jarrettmeyer
Created June 21, 2010 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarrettmeyer/447112 to your computer and use it in GitHub Desktop.
Save jarrettmeyer/447112 to your computer and use it in GitHub Desktop.
/// <summary>
/// Get all HTTP POSTed Files that were uploaded as part of a
/// multipart form POST. This abstraction keeps the controller
/// from dealing with the Request object directly.
/// </summary>
public IEnumerable<HttpPostedFileBase> HttpPostedFiles
{
get
{
// _httpContext has been pre-assigned to be the current HttpContextBase
// object running on the server.
return _httpContext.Request.Files.Cast<string>()
.Select(httpFile => _httpContext.Request.Files[httpFile])
.Where(postedFile => postedFile.ContentLength > 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment