Downloading files


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?

leoleoAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
dmagConnect With a Mentor Commented:
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
 
powerlordCommented:
Actually, it's better to use application/octet-stream which is the "default" Binary filetype.
0
 
leoleoAuthor Commented:

Can you explain it a bit further?
0
 
leoleoAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.