KingOfHeart Posted May 13, 2010 Share Posted May 13, 2010 Is there a function to download a file that is normally blocked by .htaccess When a user uploads a file, I don't want it to be accessible until after it's approved. If there is no function, maybe I can copy the file, force a download, and delete it? Link to comment https://forums.phpfreaks.com/topic/201678-download-a-blocked-file/ Share on other sites More sharing options...
KingOfHeart Posted May 13, 2010 Author Share Posted May 13, 2010 After searching the web, I found a script. function Download($file) { if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } } So far this script works fine. Link to comment https://forums.phpfreaks.com/topic/201678-download-a-blocked-file/#findComment-1057990 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.