Simple Function To Force Download Of A File
The following function will allow you to run a file download through PHP, you could use this to help with tracking of downloads on a site for example. Or to force a Powerpoint file to download rather than open in the browser, no matter what the users browser settings.
Note however that if you are doing file integrity checksums (md5, sha1, etc.) against the file the file passed through in this way will not have the same checksum as the file when saved on the client machine or the file stored on the server.
-
-
//-----------------------------------------------
-
// Function to force download of a file
-
//-----------------------------------------------
-
public function download($file_name, $file_path, $mime_type)
-
{
-
}
Related posts on coderchris.com:
- PHP5 Universal File Download Class
After finding different hosting companies having wildly different policies when it comes to what's enabled... - ctype_digit rtfm!
For the last 5-10 minutes I've been wondering why a check on a variable which... - Dodgy Wordpress Plugins and Themes
Recently I have been doing a LOT of research into various wordpress themes and plugins... - File-system mp3 Organisation – Is It Really That Hard?
Like most people I know I have a lot of mp3's and every person likes... - Why @ is NOT your friend
Ah, the error suppression operator (@) It seems like such a fantastic idea, just put...
Categories: PHP

Also Find Me On