OK, I have a directory and file within it I want people to download: /directory/file.ext I wanna have this as a file download, and am using the following code, which is a modified version of someone elses. It returns the download I want, but just an empty file. $fullPath = '/directory/file.ext'; $fd = file_get_contents($fullPath); $fsize = filesize($fullPath); $path_parts = pathinfo($fullPath); //$ext = strtolower($path_parts["extension"]); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment;filename=\"".$path_parts["basename"]."\""); header("Content-length: $fsize"); header("Cache-control: private"); //use this to open files directly echo $fd; exit; PHP: Somethings going to be wrong and I'm guessing it's the file_get_contents and echo $fd thing. Thank you.
<?php $file = '/directory/file.ext'; 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; ?> PHP: