PDA

View Full Version : Automatically "Save Target As..."



tcampbell
06-19-2008, 02:57 PM
How can visitors simply click on a download link and have a box pop up automatically for them to rename and save the document to their computer without having to right click on the download link and click "Save Target As..."? I have seen this done on many sites but I don't know how they do it.

I hope someone can help me.

www.TannersSermons.com/sermons.html (http://www.TannersSermons.com/sermons.html)

Watdaflip
06-20-2008, 09:25 AM
There are multiple ways of doing it. The easiest in my opinion is just adding some lines of code to your .htaccess file in the directory that contains the files you want your users to download

example:


AddType application/octet-stream .avi
AddType application/octet-stream .mpg
AddType application/octet-stream .wmv
AddType application/octet-stream .mp3


Just change the .avi, .mpg... whatever to the file extension of the files you want to be downloaded. This way when they click the link it will download instead of opening. (meaning they won't have to right click and save)

Hope that helps

tcampbell
06-20-2008, 08:55 PM
Thanks for your response. I did everything according to your instructions (at least I think I did): I put the code

AddType application/octet-stream .wma

on the .htaccess file, which changed the pictures of all the wma files in that directory to a blue diamond image (so I guess I did something right), but on the site, the files still just open when I click on the download link, unstead of downloading. What did I do wrong?

Watdaflip
06-20-2008, 10:46 PM
I don't know how your have your file structure setup, but it may be an issue with the paths to the files in relation to the .htaccess file. Try just adding it to the .htaccess file in your public_html directory. That should effect all other directories globally.

If that doesn't work then there is way to do it with php, but if you have a bunch of files it would either mean creating a php file for each download you have, using an predefined list of files that can be downloaded and use url variables to choose which file, or to use a database to manage the files that will be downloaded.

tcampbell
06-21-2008, 12:03 AM
Thanks again for the response, I'll give it a try.