php - Force download and htaccess = zero bytes files -
i trying deny access folder on server, in there files can downloaded via php script. php script used force download of files, that:
function downloadfile($file){ $file_name = $file; $mime = 'application/force-download'; header('pragma: public'); header('expires: 0'); header('cache-control: must-revalidate, post-check=0, pre-check=0'); header('cache-control: private',false); header('content-type: '.$mime); header('content-disposition: attachment; filename="'.basename($file_name).'"'); header('content-transfer-encoding: binary'); header('content-length: '.filesize($file_name)); // provide file size header('connection: close'); readfile($file_name); exit(); } and htaccess must provide access localhost:
order deny,allow deny allow 127.0.0.1 but every time script download 0 bytes files same name, instead of complete file. when delete htaccess, however, fine.. can't figure out error. help
the problem readfile(); need absolute path of file on machine rather url.
e.g. /home/person/file.exe
Comments
Post a Comment