curl - Allow access to protected file through PHP -


i have set of tar.gz files inside folder protected against http access via .htaccess. wish allow direct curl downloading of these files via http. have done things images setting header information like:

$file='/some/file/protected/by/htaccess.png'; header("content-type: image/png"); readfile($file); 

my question: there way provide direct access these tar.gz files in similar manner way did images?

the reason in way control access users can access these files our site's login system.

edit: pointed out machavity, code pointing @ jpg, , had png header.

for tar.gz

$filename = 'path/to/your/file.tar.gz'; header('content-type: application/x-compressed'); header("cache-control: no-store, no-cache"); header('content-disposition: attachment; filename="' . basename($filename) . '"'); header('content-length: ' . filesize($filename)); readfile($filename); 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -