| 
 Posted by Mateusz Markowski on 11/02/06 08:55 
David napisal(a): 
> Is there a way to download a file from a directory not in the server's 
> path?  Eg. not under public_html?  This would be for security so that 
> the files can never be directly access vial the web. 
> 
> I did a search on PHP + download but this garnered many unless web 
> sites. 
> 
 
Yes, there is. You can use header() with readfile(), for instance: 
 
//file to send 
$file = '/etc/passwd'; 
 
//headers to tell browser that we want to send file 
header('Content-Type: application/octet-stream'); 
header('Content-Length: ' . filesize($file)); 
 
//reads file and sends it to client 
@readfile($file);
 
  
Navigation:
[Reply to this message] 
 |