/ Published in: PHP
provide file via URL var, and script will grab it & force download. Take a look at code, and add some of your filetypes if required
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$file_name = $_GET['file']; // make sure it's a file before doing anything! { /* Do any processing you'd like here: 1. Increment a counter 2. Do something with the DB 3. Check user permissions 4. Anything you want! */ // required for IE // get the file mime type using the file extension { case 'pdf': $mime = 'application/pdf'; break; case 'zip': $mime = 'application/zip'; break; case 'jpeg': case 'jpg': $mime = 'image/jpg'; break; default: $mime = 'application/force-download'; } }