473,762 Members | 7,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PostedFile.Cont entType returns "applicatio n/octet-stream" instead of "applicatio n/vnd.ms-excel"

I'm using an html input control
(System.web.UI. HTMLControls.HT MLInputFile) to upload files such as
msword, excel, jpg, and pdf.

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

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

Private Sub btnUploadFile_C lick(ByVal sender As System.Object, ByVal e

As System.EventArg s) Handles btnUploadFile.C lick

If UploadFile.Post edFile.FileName <> "" Then

Dim imgdatastream As Stream =

UploadFile.Post edFile.InputStr eam

Dim imgdatalen As Integer =

UploadFile.Post edFile.ContentL ength

Dim imgtype As String = UploadFile.Post edFile.ContentT ype

---
--
---
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
"applicatio n/octet-stream". instead of "applicatio n/msword" or
"applicatio n/vnd.ms-excel"
The uploaded files are saved as image in SQL server 2000.
Since the content type is "applicatio n/octet-stream", while
downloading the files using httphandler funtionality, the files get
downloaded as

"test.xls.a spx"
"test.doc.a spx"
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
"applicatio n/vnd.ms-excel", so while downloading they download as
"test.xls.x ls"
"test.doc.d oc"

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

Thanks,
Chanda.
Nov 18 '05 #1
2 15505
CVerma wrote:
I'm using an html input control
(System.web.UI. HTMLControls.HT MLInputFile) 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 "applicatio n/vnd.ms-excel". If word,
then "applicatio n/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
17577
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 where else... Can any one give me good example how to create pdf file on the fly and write just "hello"? Also checked on expert - exchange but things couldnt work for me... http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21239281.html ...
1
3376
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 .Buffer = True .Clear()
4
2069
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 of the server and path to my application, such as: http://devserver/testapp However, on 1 of my test servers, it returns:
4
1662
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 System.Web.HttpApplication but it does not seem to like that one bit. I also have a MSXML2.DOMDocument30 defined as a public object within the vb module which is loaded during the application start up with a bunch of XML. What is weird is that the data contained...
5
4972
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
1777
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
1645
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 on by default. It appears as though it might be <w:SpellingState>Clean</w:SpellingState>. However, I haven't found any web sites that discusses what alternative values of this tag might will accept. Any help would be greatly appreciated.
13
2305
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 could add a directory to my project (say, "Controls"), then add a user control to that directory. From an .aspx I could then import the namespace ("using .Controls";), and then reference that control. With the 2.0 way of doing things, if I add a...
4
61892
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. I get the same response with: Response.ContentType="Application/X-unknown" which is more understandable. The Response.ContentType="Application/pdf" doesn't seem to tell the browser
0
1611
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 is that I made an empty ASP.NET AJAX- Enabled Web Application instead of an ASP.NET Web Application. Before converting, there were some classes in the App_Code folder. After converting, the folder was renamed Old_App_Code. But now I get...
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9377
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9925
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6640
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.