This was posted on 12/01/2010 and was filed in Tips And Tricks, Guides and Information, .htaccess | (No Comments Yet)
I was asked how we could force a user to 'download' a file without using php to alter the header. This htaccess script will force users to DOWNLOAD anything a folder, rather than viewing it in their browser. Really useful when you want to do things like music downloads, image donwloads, etc. because it saves the user the step of File > Save As, then navigating back to your site. The example below applies to ANY file in the directory and any children of the directory that your .htaccess file resides.
ForceType applicaton/octet-stream
</files>
Simply link to a file in your folder with this snippet, and any file accessed will have to be downloaded. We can even restrict this to certain filetypes. In this case below, it is only applied to mp3 files.
ForceType applicaton/octet-stream
</files>
Have I Helped You? Share Some Love!
Comments
» No Comments have been made on this. How about you start us off?
Comment On This
Browse By Category
- All Posts
- Useful Websites
- Money Savers
- Tips And Tricks
- Social Media
- Guides and Information
- PHP
- How-Tos
Latest Posts
- » PHP Unserializer
- » How To: Quickly Add a New PHP Extension Via SSH
- » Easily Open A TCP Port On Your Stock cPanel Server
- » Free Code: Find The Total Line Count Of A Folder Using PHP
- » Free Code: ReCaptcha Form Validation With PHP
- » View All
Advertising
© Max Morgan Design 2009 - 2012 | Page Generated In 0.17817 Seconds Using 42 MYSQL Queries


