I have a function which extracts a file into a byte array (data).
int contentLength = postedFile.ContentLength; byte[] data = new byte[contentLen
You're not checking the return value of postedFile.InputStream.Read. It is not at all guaranteed to fill the array on the first call. That will leave a corrupt JPEG in data (0's instead of file content).