In InfoPath 2007, including browser enabled forms, you have the ability to use a control called "File Attachment". When rendered in the browser, it looks like this -
What it has done is, it has embedded a bunch of information, as a byte stream, right inside the XML. Specifically, the filename, and filebytes are embedded.
How can you extract that attachment, in code?
Step #1 - create a strongly typed representation of your form, as I illustrated in this blogpost.
Step #2 -
Now assuming that your field name was "fldImage", and assuming that the file uploaded was an Image, you can use the following code to extract the filename, and the file itself -
2: byte imageBytes = fields.fldImage;
3: MemoryStream ms = new MemoryStream(imageBytes);
4: BinaryReader theReader = new BinaryReader(ms);
5: theReader.ReadBytes(16); // Skip the header data.
6: int fileSize = (int)theReader.ReadUInt32();
7: int attachmentNameLength = (int)theReader.ReadUInt32() * 2;
8: byte fileNameBytes = theReader.ReadBytes(attachmentNameLength);
9: Encoding enc = Encoding.Unicode;
10: string attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength - 2);
11: byte decodedAttachment = theReader.ReadBytes(fileSize);
12: Image img = Image.FromStream(new MemoryStream(decodedAttachment));
13: img.Save("testimage.jpg", ImageFormat.Jpeg);