glenelkins Posted February 28, 2006 Share Posted February 28, 2006 [code]function downloadFile($thefile) { header ("Pragma: public"); header ("Expires: 0"); header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header ("Cache-Control: public"); header ("Content-Description: File Transfer"); header ("Content-Length: ".filesize($thefile)); header ("Content-Disposition: attachment; filename=".$thefile); header ("Content-Transfer-Encoding: binary"); $fopen = fopen($thefile); fpassthru($fopen); fclose ($fopen);}[/code]Ok why when the file download box comes up with the correct file path passed to the function, does it download the file but it wont open images etc, and text documents come up with a load of rubbish or they display some of the code from the download page. Quote Link to comment https://forums.phpfreaks.com/topic/3741-download-file/ Share on other sites More sharing options...
schme16 Posted August 29, 2007 Share Posted August 29, 2007 <?php header('Content-type: application/octet-stream'); readfile($filename); exit;?> Quote Link to comment https://forums.phpfreaks.com/topic/3741-download-file/#findComment-337164 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.