943,935 Members | Top Members by Rank

Ad:
Nov 17th, 2005
0

Output to text (notepad) file

Expand Post »
Hi,

I'm trying to write an html page that ends up being a text file to be opened in notepad. What content type do I use so that when you click on the link the output gets put into a text file and the user is prompted to open/save?

Do you have a sample?

Thanks,
winbatch
Similar Threads
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005
Nov 17th, 2005
0

Re: Output to text (notepad) file

The MIME-type should be text/plain. However, you should also give your file the .txt file extension, because IE ignores MIME-types, using instead the OS' file associations.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Nov 17th, 2005
0

Re: Output to text (notepad) file

Quote originally posted by tgreer ...
The MIME-type should be text/plain. However, you should also give your file the .txt file extension, because IE ignores MIME-types, using instead the OS' file associations.
Can you give me a sample of how to set it? Basically the page is simply displaying the words (and then the text):

Content-Type: text/plain

but the browser is not acting on it and serving it up for me to download..
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005
Nov 17th, 2005
0

Re: Output to text (notepad) file

What server-side language are you using to create the file? Here's a PHP example:

HTML and CSS Syntax (Toggle Plain Text)
  1. <?
  2. header("Content-type: text/plain");
  3. ?>

You can provide a meta-tag, however, it may not work in all browsers. The proper way is to set the MIME-type in the HTTP headers (which is what PHP is doing, above), rather than in the HTML document itself. The meta-tag:

HTML and CSS Syntax (Toggle Plain Text)
  1. <META HTTP-EQUIV="Content-Type" CONTENT="text/plain">

That would go in the "head" section of your HTML.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Nov 17th, 2005
0

Re: Output to text (notepad) file

perl (but only because that's what the pages written by somebody else are written in...)
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005
Nov 17th, 2005
0

Re: Output to text (notepad) file

HTML and CSS Syntax (Toggle Plain Text)
  1. print "Content-Type: text/plain; charset=utf-8\n\n";

Put this before any page content.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: CSS External Linking Problems
Next Thread in HTML and CSS Forum Timeline: Hidden Counter





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC