Download file from non public html folder with php -



Download file from non public html folder with php -

i have number of files stored on server, not in public_html directory. thought users logged in can download files, using $_session variables check if logged in, if else uses computer can not see direct file path in browser history , if outside public html directory not accessible.

i know need script this, can't find out how where, appreciated if tell me how this.

you can utilize readfile output file in question. eg:

$file = '/absolute/path/to/file.ext'; if (file_exists($file)) { header('content-description: file transfer'); header('content-type: application/octet-stream'); header('content-disposition: attachment; filename='.basename($file)); header('content-transfer-encoding: binary'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('pragma: public'); header('content-length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; }

php

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -