Prompt for Download when linking to a file

Hey everyone.. I was wondering if there was a way to prompt the user to "open, save, cancel" when they click on a link that goes to a file on the server... Right now... when the link is clicked... it just opens up the file.  Is there a way to do this??

Thanks for the help.
LVL 1
every1isevilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StormyWatersCommented:
The simplest way would be to zip the file.  Otherwise you need to use some serverside scripting to set the content-type of the file to application/octet-stream. I can give more details if that's the option you want.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
seanpowellCommented:
Stormy's correct (basically octet-stream means I'm not going to tell the browser what the file is, so it has no other option but to prompt.)

If you use asp, there is also another option. This is my favorite tutorial for handling it.
http://www.xefteri.com/articles/show.cfm?id=7

Sean
dorwardCommented:
Sending the file as application/octet-stream isn't ideal, sending it with a Content-Disposition: attachment header as seanpowell suggests is rather better - you don't need ASP for it though, you can send the headers with whatever language you choose.

Quick, nasty and untested Perl example:

print "Content-type: text/html\n";
print "Content-Disposition: attachment; filename = myFile.html\n\n";
open (FILE, "/path/to/file.html");
while (<FILE>) { print $_; }
close (FILE);
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

samtran0331Commented:
every1isevil, (<--- just a tad cynical eh?) =0)

Is there a specific filetype you are dealing with? Or do you need a solution for *any* file type?
Are you noticing this on all computers, or just one?

Depending on your answer to the above, one of the possible problems is that the setting in windows o/s got changed.
There is a setting in windows that you set to tell the browser what to do with the file.

Open up any Windows Explorer window, then from menu, Tools>Folder Options>File Types (tab)
Select a file extension and click the "Advanced" button, there is a checkbox
"Confirm open after download", for most extensions, this is checked by default.

could be the specific pc you are working on, that this setting got changed. If it's not checked, the default application will launch and open the link as soon as you click it.

sknightCommented:
I believe this is what you are looking for:
http://www.asp101.com/samples/download_sample.asp
sknightCommented:
I believe this is what you are looking for:
http://www.asp101.com/samples/download_sample.asp
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.