Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > PostedFile.ContentType returns "application/octet-stream" instead of "application/vnd.ms-excel"

Reply
Thread Tools

PostedFile.ContentType returns "application/octet-stream" instead of "application/vnd.ms-excel"

 
 
CVerma
Guest
Posts: n/a
 
      09-23-2004
I'm using an html input control
(System.web.UI.HTMLControls.HTMLInputFile) to upload files such as
msword, excel, jpg, and pdf.

I have the encType property set in the form:
encType="multipart/form-data"

<INPUT id="UploadFile" type="file" name="UploadFile" runat="server">

Private Sub btnUploadFile_Click(ByVal sender As System.Object, ByVal e

As System.EventArgs) Handles btnUploadFile.Click

If UploadFile.PostedFile.FileName <> "" Then

Dim imgdatastream As Stream =

UploadFile.PostedFile.InputStream

Dim imgdatalen As Integer =

UploadFile.PostedFile.ContentLength

Dim imgtype As String = UploadFile.PostedFile.ContentType

---
--
---
more code to add the file to a record and store in SQL server

End If

End Sub


Problem: I have 3 different servers on which the above function works
fine. But on one server which is behind firewall and has certificate
installed on it, the excel and word files return ContentType as
"application/octet-stream". instead of "application/msword" or
"application/vnd.ms-excel"
The uploaded files are saved as image in SQL server 2000.
Since the content type is "application/octet-stream", while
downloading the files using httphandler funtionality, the files get
downloaded as

"test.xls.aspx"
"test.doc.aspx"
If I save the above files as "test.xls", the files are in right
format. But from users point of view, it should save as test.xls.xls
in the first place.

AND on the other servers, same files have content type as
"application/vnd.ms-excel", so while downloading they download as
"test.xls.xls"
"test.doc.doc"

Does anyone know what could be the reason for the files having the
contenttype as "application/octet-stream".

Thanks,
Chanda.
 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      09-24-2004
CVerma wrote:
> I'm using an html input control
> (System.web.UI.HTMLControls.HTMLInputFile) to upload files such as
> msword, excel, jpg, and pdf.
>


I wonder, where is the ContentType set? It is possible that this is done on the
client. If this is so, and the client you tested from doesn't know about ".xls"
files, then it would return the "unknown binary" mimetype, application/octet-stream.

Hans Kesting


 
Reply With Quote
 
 
 
 
C Verma
Guest
Posts: n/a
 
      09-27-2004
Hi Hans,
Thanks for your input. I figured the same. TO slove the problem, I am
finding the extension of the file being uploaded and if it is excel,
then I am setting contentType to "application/vnd.ms-excel". If word,
then "application/msword"

However I don't know what all files a user can upload, I am limiting
myself to word and excel because there are the extensively uploaded
files on our website.

Thanks,
Chanda.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorted Returns List and Reversed Returns Iterator ++imanshu Python 7 08-23-2008 04:25 AM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
createImage sometime returns null and sometime returns non-null. vizlab Java 3 10-17-2007 11:21 AM
block returns and hash element returns Trans Ruby 2 11-06-2005 12:15 PM
dr("field").toString returns "400.0000" instead of "400" Dan C Douglas ASP .Net 5 07-22-2003 05:48 PM



Advertisments