Created
August 13, 2014 10:54
-
-
Save ramainen/514a76743bedbbc7bbf3 to your computer and use it in GitHub Desktop.
file download attachment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function download_file($adress){ | |
$adress = str_replace('+',' ',$adress); | |
$file = d()->File->where('title = ?',$adress); | |
header('Content-Description: File Transfer'); | |
header('Content-Type: application/octet-stream'); | |
header("Content-Disposition: attachment; filename*=UTF-8''".rawurlencode( $file->title).'.'.$file->ext.""); | |
header('Content-Transfer-Encoding: binary'); | |
header('Expires: 0'); | |
header('Cache-Control: must-revalidate'); | |
//header('Pragma: public'); | |
//header('Content-Length: ' . filesize($file)); | |
ob_clean(); | |
flush(); | |
readfile($_SERVER['DOCUMENT_ROOT'] . $file->file); | |
exit(); | |
print $file->ext; | |
print $file->file; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment