Jump to content

Download file


glenelkins

Recommended Posts

[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.
Link to comment
https://forums.phpfreaks.com/topic/3741-download-file/
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.