CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Downloadable text file!

 



okalani
Deleted

Nov 23, 2000, 8:30 PM

Post #1 of 3 (306 views)
Downloadable text file! Can't Post

I'm trying to make a text file downloadable but with little success. I have a cgi script that is generating some information on the fly and I want the user to download the text file rather than having the text file displayed or haveing them go through the trouble of clicking on the File menu to save it.

I tryed using various Content types which did allow me to download the text file but it placed all the data on one line rather than keeping the integrity of the data structure.

Now I know this can be done because I'm able to do this with my credit card processing company where I can download a batch file file as a text file.

I've been trying to figure this out for over a month. Any solution will be greatly appreciated.

Ikaika


chrisabrooks
Novice

Nov 25, 2000, 2:41 AM

Post #2 of 3 (306 views)
Re: Downloadable text file! [In reply to] Can't Post

The problem here is that most browsers will just display the txt file, because they just see it as some text which they can display. To my knowledge, you cannot make a txt file download, without being viewed, except by maybe a fancy javascript or something... :)

Hmm, just an afterthought... Could you use a system(" "); command and make it zip the text file, so it's downloadable? It's kinda a long shot, and you've gotta know you're UNIX commands, but it might work... :)

------------------
My Little Webring
The Best Of All That Is British
chris.a.brooks@lycos.com
Cult Forums - Cult CGI forum

Linux - Join the revolution!!!



kencl
User

Nov 28, 2000, 8:37 PM

Post #3 of 3 (306 views)
Re: Downloadable text file! [In reply to] Can't Post

I've been trying to figure this out for about an hour now, just because it intrigued me. I found a good set of articles on mime-types (albiet from an ASP perspective). Don't forget to read part two (the link is in the last paragraph).

One problem I had was that the downloaded file is the name of my cgi script!
On my system, since I have the .cgi extension associated with notepad, and I've allowed it to open automatically, the "download or open" dialog box does not come up. I was able to turn this automatic opening off by going to Tools - Folder Options - File Types in Windows Explorer, selecting my CGI extension, choosing OPEN then the edit button, then unchecking the "confirm after download" option.

I also found that the text displayed on one line in notepad, but wordpad managed to see it properly. I had to save the file as text from wordpad and reopen it to see it properly in notepad.

Incidentally, I didn't find a definitive list of all mime-types. If anyone comes across that, please post it here.

Hope this helps.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives