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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -