?
Solved

Text files opening up as html instead of Notepad/Wordpad in IE

Posted on 2004-10-22
8
Medium Priority
?
350 Views
Last Modified: 2008-01-16
I have a web application that allows a user to download a etxt file within their browser. Several end users have reported that after applying XP SP2 the files open up in IE as html. Is there a way to change this so that the IE uses Notepad/Wordpad to open the files?

Thanx
0
Comment
Question by:factsmgt
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:lepiaf
ID: 12381148
Are text files associated to IExplorer?

You can view that in the files properties, in the 1st tab under opens with APP_NAME -> hit the change button, in case it is associated to IExplorer.

is that the issue?

cheers,
LePiaf
0
 

Author Comment

by:factsmgt
ID: 12382222
text files are associated with Notepad. If I open the file through Windows explorer the file will open in Notepad.
0
 
LVL 4

Expert Comment

by:Danielcmorris
ID: 12387472
Here ya go:

<%
Response.Buffer = True

strFileName=request("strFileName")        ' Set file name
strFilePath=server.mappath(strFilename) ' Set path of file
set fso=createobject("scripting.filesystemobject")
set f=fso.getfile(strfilepath)
strFileSize = f.size
set f=nothing: set fso=nothing
Const adTypeBinary = 1
Response.Clear
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
strFileType = "application/text" ' change to the correct content type for your file
Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
Response.AddHeader "Content-Length", strFileSize
Response.Charset = "UTF-8"
'Response.ContentType = strFileType
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%>

make a new page.  paste this script into it.  call it "forcedownload.asp".  make the link on your file something like:

<a href="forcedownload.asp?strFileName=my_text_file.txt">my text file</a>

It will force the user to download the file rather than opening it up in the browser.  Very nice.  I got it from some site a long time ago.  (maybe even this one)  It has saved me a huge amount of trouble.  Especially because you can set the file path to someplace other than your website.  Places where you don't want people to be able to browse to.  

Good luck,

-Dan
 
0
 

Author Comment

by:factsmgt
ID: 12535564
Does anyone have any insight on how to correct this on the client side?
0
 
LVL 4

Accepted Solution

by:
Danielcmorris earned 500 total points
ID: 12536490
It would be an incredible pain in the butt.  You may be able to set your user's computers to disassociate IE with txt files, but I couldn't tell you how to do it.  

If you REALLY wanted to fix it so your XP users would get notepad, you can create a little activex object that would pull the document off your site, save it to a temp file, then open that file with notepad.

Then again, you'd have to screen the users so only Windows users would get the ActiveX.  For linux and mac, well.... a Java app.  All around Yuck.

0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

No other job is as rewarding and demanding as building an iPhone app is. It is not really in the hands of the developer for the success of an iPhone app. Many factors operate jointly for every iOS application's success in the market.
Before you approach an Ionic Mobile App development company for developing mobile apps using the ionic framework, you must know why you should choose the framework. Let's try to understand that through this article.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month4 days, 3 hours left to enroll

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question