Solved

Downloading files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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.…
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 explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

943 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

5 Experts available now in Live!

Get 1:1 Help Now