473,408 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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

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.
Nov 18 '05 #1
2 15449
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
Nov 18 '05 #2
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!
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: dave | last post by:
Hello Can any one suggest me how to create pdf on the fly... I had already checked link http://www.aspfaq.com/show.asp?id=2207 but I cannot use third party component as site is not hosted some...
1
by: Zoury | last post by:
Hi Folks ! :O) In a web application, I'm trying to load a PDF document in the client's browser. The following code works on my workstation but fails on another one : '*** With Response...
4
by: Julie | last post by:
I stumbled across Application from someone else's code, and I can't find out squat about by searching MS, Google, or Google Groups. For the most part, this is returning the fully-qualified name...
4
by: Keith Chadwick | last post by:
I am having some trouble referencing an Application("myVar") variable from within a module.vb file on my ASP.NET site. According to the documentation I should be able to reference...
5
by: TJS | last post by:
trying to display pdf file in browser fails on this line: Response.ContentType = "application/pdf" getting an error about no declaration found for "response" what declaration is needed ???
6
by: farmer | last post by:
Compiler Error Message: CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement And: (int)Application++; Makes no sense.
0
by: ASP Developer | last post by:
For some reason when I direct my users to a word document via Response.ContentType = "application/word" the spell check is turned off. Does anyone know which smart tag needs to be mofied to have it...
13
by: Kobee | last post by:
Hi, I'm having a few issues adapting to new 2.0 "website" project vs. the old 1.1 "web application". One of the major issues I'm having is with the notion of namespaces. Using the old way, I...
4
by: Bjorn Sagbakken | last post by:
With ASP.NET 2.0 I'm trying to display the pdf file directly in the client browser, but I only get a download dialogue box. Downloading the file works fine, but I want to view the PDF directly. ...
0
by: clintonb | last post by:
I converted a Web Site project to a Web Application project using the instructions found on this page: http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx One thing I did differently...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.