Evan T. Basalik
12/12/2002 9:17:00 PM
I'm using an html input control to upload files such as msword, excel,
jpg, and pdf. The control I'm using is:
<INPUT id="inpUploadFile" type="file" name="inpUploadFile"
runat="server">
The code behind looks like:
Private Sub btnUploadFile_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnUploadFile.Click
If inpUploadFile.PostedFile.FileName <> "" Then
Dim imgdatastream As Stream =
inpUploadFile.PostedFile.InputStream
Dim imgdatalen As Integer =
inpUploadFile.PostedFile.ContentLength
Dim imgtype As String = inpUploadFile.PostedFile.ContentType
Dim imgdata(imgdatalen) As Byte
Dim n As Integer = imgdatastream.Read(imgdata, 0, imgdatalen)
? more code to add the file to a record and store in SQL server
End If
End Sub
I have the encType property set in the form:
encType="multipart/form-data"
Problem: Uploads of various different file types work fine including
uploading of Word files containing small images (gif or jpg of size
~15KB). However when I upload a Word file with a large image (gif or
jpg of size ~53KB) inserted into the Word file, the
PostedFile.ContentType is not "application/msword" as it usually is
for Word files. It is instead "application/octet-stream". Then when
the row is inserted into SQL server, a "severe error" occurs.
Anyone have insight on this?
Thanks,
Evan