|
-
Oct 27th, 2006, 12:18 PM
#1
Thread Starter
New Member
file transfer type issue
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!
-
Nov 2nd, 2006, 02:37 PM
#2
Thread Starter
New Member
[Resolved] file transfer type issue
I figured this out myself: I had the user right-click on the document in question and click on Open With, then explicitly selecting the program (WORD or Excel) to open the document. This associates the file extension with the program.
He was then able to use the normal appplication program I noted above to upload these documents into SQL. This time they both had the expected Content Type and were readable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|