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:
Choose name for a downloadable "text" file!

 



stefan
stranger

Nov 16, 2001, 6:34 AM

Post #1 of 4 (577 views)
Choose name for a downloadable "text" file! Can't Post

I'm trying to make a .hex file(basically a text file) downloadable but with some success. I have a cgi script that is generating some information on the fly with the information gathered from a form and I want the user to download the .hex file.

I have success fully made the file downloadable BUT the name of the file will end up to be the name of the script. I tried using various Content types, but a probably hasnít find the right one.

Any solution will be greatly appreciated.

Stefan



Kanji
User

Nov 16, 2001, 10:12 PM

Post #2 of 4 (571 views)
Re: Choose name for a downloadable "text" file! [In reply to] Can't Post

A trick I've turned to is using tacking on the desired download name after the script name so that you end up with something like /download.pl/saved-as.hex, which fools most browsers into thinking saved-as.hex is the proper name.

This only works if your web servers supports the extra PATH_INFO capabilities (accessed via path_info() if you use CGI.pm or $ENV{'PATH_INFO'} if you don't).



WilliamC
stranger

Nov 17, 2001, 12:04 AM

Post #3 of 4 (569 views)
Re: Choose name for a downloadable "text" file! [In reply to] Can't Post

why not go to the next step and just send it as an attachment to an email? This also allows you to gather email addresses legally.



PerlCoders CGI Supersite
http://www.perlcoders.com


stefan
stranger

Nov 18, 2001, 11:26 PM

Post #4 of 4 (563 views)
Re: Choose name for a downloadable "text" file! [In reply to] Can't Post

This seams like a good idea if you have a link but in my case I have "download" button. The only way of telling the browser the .hex filename is through the perl-code. You can see my form at: www.anderssonsskomakeri.se/cgi-bin/hexcad.pl,
and you can see my script attached

I have succeded. The magic perl-code was:
print "Content-type: text/hex", "\n";
print "Content-Disposition: attachment; filename=noname.hex\n\n";

Thanks for all help!


(This post was edited by stefan on Nov 18, 2001, 10:57 PM)

 
 


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

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