I'm trying to download a file through my server to me, by streaming the download.
This is my script:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=http://user:[email protected]/file.bin';
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: ' . $r[2]);
ob_clean();
flush();
readfile($fileName);
exit;
example.com isn't what I'm really using, I just didn't want to show the real URL. :) When I go to this file in my web browser a download prompt does not come up and nothing happens. $r[2]
is the content length in bytes of the file and $fileName
is the same URL as used in the attachment header. I really don't know what I'm doing wrong.