A PHP script to let users download a file from my website without revealing the actual file link in my website? -
A PHP script to let users download a file from my website without revealing the actual file link in my website? -
the question says all.. how allow users download file website , not allow them see link file comes from? understand there might need download.php serve gateway past phase, dunno script next... if bothers write whole code, few function names should need utilize handy!
find way identify file download (for instance, variable matches id of row in database, or along these lines). create damn sure it's valid one, because don't want users able download off site. then, utilize header
content-disposition
tell browser file should downloaded, , readfile
output it.
for instance:
<?php $id = intval($_get['id']); $query = mysql_query('select file_path files id = ' . $id); if (($row = mysql_fetch_row($query)) !== false) { header('content-disposition: attachment; filename=' . basename($row[0])); readfile($row[0]); } exit; ?>
php file scripting download hide
Comments
Post a Comment