Page 1 of 1

download script?

Posted: Sun Jan 22, 2006 6:44 am
by soul814
How do you create a download script that like masks where the file is coming from

Posted: Sun Jan 22, 2006 7:54 am
by Chris Corbyn
Been asked many times.

Code: Select all

<?php

$path_to_file = '/home/username/private/foo.pdf';

header('Content-type: application/pdf');
header('Content-length: '.filesize($path_to_file));
header('Content-disposition: attachment; filename=foo.pdf');
fread($path_to_file);
exit();

?>

Posted: Sun Jan 22, 2006 8:53 am
by feyd
psst, readfile() not fread() :P

Posted: Sun Jan 22, 2006 9:05 am
by Chris Corbyn
feyd wrote:psst, readfile() not fread() :P
*cough*

/me awards feyd the prize jar of ross' pickled onions for spotting the deliberate mistake :lol:

Posted: Sun Jan 22, 2006 10:08 am
by foobar
d11wtq wrote:/me awards feyd the prize jar of ross' pickled onions for spotting the deliberate mistake :lol:
You were only testing him, eh? :wink:

Posted: Sun Jan 22, 2006 4:32 pm
by soul814
well thanks =) lol nice test lol