download script?
Moderator: General Moderators
download script?
How do you create a download script that like masks where the file is coming from
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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();
?>- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia