User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 397,865 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,530 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 3860 | Replies: 5
Reply
Join Date: Feb 2005
Posts: 461
Reputation: winbatch is on a distinguished road 
Rep Power: 4
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Output to text (notepad) file

  #1  
Nov 17th, 2005
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Output to text (notepad) file

  #2  
Nov 17th, 2005
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.
Reply With Quote  
Join Date: Feb 2005
Posts: 461
Reputation: winbatch is on a distinguished road 
Rep Power: 4
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Output to text (notepad) file

  #3  
Nov 17th, 2005
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..
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Output to text (notepad) file

  #4  
Nov 17th, 2005
What server-side language are you using to create the file? Here's a PHP example:

<?
header("Content-type: text/plain");
?>

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:

<META HTTP-EQUIV="Content-Type" CONTENT="text/plain">

That would go in the "head" section of your HTML.
Reply With Quote  
Join Date: Feb 2005
Posts: 461
Reputation: winbatch is on a distinguished road 
Rep Power: 4
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Output to text (notepad) file

  #5  
Nov 17th, 2005
perl (but only because that's what the pages written by somebody else are written in...)
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Output to text (notepad) file

  #6  
Nov 17th, 2005
print "Content-Type: text/plain; charset=utf-8\n\n";

Put this before any page content.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb HTML and CSS Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 8:55 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC