Solved

Downloading files

Posted on 2000-02-21
4
136 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now