I have a asp.net app written in VB.net 2003. Users have the ability to upload a file to attach to the items they create in the application.

The control is FileToUploadHTMLInput and attachments get stored in SQL.

One of my users can upload a WORD doc via the app, but when he tries to open that uploaded file (via clicking on the relevant row in the datagrid which lists the available attachments), the uploaded file was unreadable. And, instead of having the .doc extension, the Content-Type, as displayed in the datagrid, was "Application/octet-stream".

The same things occurred again when he tried to upload an Excel spreadsheet. Instead of the uploaded file having a ".xls" extension, it was "Application/octet-stream". It, also, could not be viewed from the application.

Note:
I was able to upload both of these files with NO problems: they both retained the extensions they were supposed to have and both files were readable when clicking on the relevant row in the datagrid.

Here's the upload code:

Code:
    
Private Sub UploadButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UploadButton.Click
        Dim byteArray As Byte()     
        Dim iFileLength As Integer = FileToUploadHTMLInput.PostedFile.ContentLength 
        ReDim byteArray(iFileLength) 

        Try
                   FileToUploadHTMLInput.PostedFile.InputStream.Read(byteArray, 0, iFileLength)
            With AddFileSqlCommand
                .Parameters("@PID").Value = Me.PID
                If DIDLabel.Text <> "" Then .Parameters("@DID").Value = DIDLabel.Text
                .Parameters("@Description").Value = FileNameTextBox.Text
                .Parameters("@Content").Value = byteArray
                .Parameters("@ContentType").Value = FileToUploadHTMLInput.PostedFile.ContentType
                .Parameters("@ContentSize").Value = iFileLength
                FConnection.Open()
                .ExecuteNonQuery()
            End With
        Catch ex As Exception
            Session("ErrorMessage") = ex.ToString
            Response.Redirect("Error.aspx")
        Finally
            FConnection.Close()
        End Try

        BindDocumentsDataGrid()
        FileNameTextBox.Text = ""
    End Sub
Can anyone explain to me why I am getting different results from my user? Can anyone explain what I need to do in order for my user to be able to upload files properly?

Thank you!