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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -