Solved

Downloading files

Posted on 2000-02-21
4
148 Views
Last Modified: 2010-03-05

Hi,

 Usually when we click on a link to download ordinary text files(or images), the browser just displays the text(or image) and we have to right-click and save. But if the file is another type, say, exe, the File Download window will pop up.

 Can I forcibly bring this File Download window irrespective of the file type?

0
Comment
Question by:leoleo
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
dmag earned 20 total points
ID: 2544884
I'm not sure it's the 'correct' way, but I just change the content-type line to something random. The browser doesn't know what to do, so it asks where to save the file.

#!/usr/bin/perl
print "Content-type: application/random\n";
print "Content-Disposition: attachment; filename='myfilename.txt'\n";
print "Here is some text for your file\n";

Even without a CGI, you could probably do:
<meta http-equiv="Content-Type" content="text/unknown"> in your HTML to get it downloaded.

-=Dan=-
Too lazy to try it :)
0
 

Expert Comment

by:powerlord
ID: 2586347
Actually, it's better to use application/octet-stream which is the "default" Binary filetype.
0
 

Author Comment

by:leoleo
ID: 2586919

Can you explain it a bit further?
0
 

Author Comment

by:leoleo
ID: 2672763
I was waiting for some better options to come up... but none did.
I used dmag 's soln finally with some slight changes.

Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stftime format 4 56
Perl modules on linux ec2 3 114
Vb script to unzip a files and rename the files 5 97
Perl File::Find alternative 1 79
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

820 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