Skip to content

Instantly share code, notes, and snippets.

@terjetyl
Created January 14, 2012 21:45
Show Gist options
  • Save terjetyl/1613007 to your computer and use it in GitHub Desktop.
Save terjetyl/1613007 to your computer and use it in GitHub Desktop.
Extension method for creating a byte array from a HttpPostedFileBase
public static class HttpPostedFileBaseExtensions
{
public static Byte[] ToByteArray(this HttpPostedFileBase value)
{
if (value == null)
return null;
var array = new Byte[value.ContentLength];
value.InputStream.Position = 0;
value.InputStream.Read(array, 0, value.ContentLength);
return array;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment