Jump to content


Download file

  • Please log in to reply
1 reply to this topic

#1 glenelkins

  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 28 February 2006 - 12:03 PM

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);
    fclose ($fopen);

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.
http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 schme16

  • Members
  • PipPipPip
  • Advanced Member
  • 97 posts
  • LocationAustralia - Queensland - Toowoomba

Posted 29 August 2007 - 11:23 AM

  header('Content-type: application/octet-stream');
I always want my code to be exciting, who wants uniform, easy to read code?
If you really want to break up the dull, try using ASP style tags every now and then, or random indentation! -jesirose on August 26, 2007

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users