Solved

Downloading files

Posted on 2000-02-21
4
154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

617 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