download file
Moderator: General Moderators
download file
any way to allow some one to download a file without letting them know the directory the file is located on the server?
Code: Select all
if(is_file('/home/path/to/directory/'.$gallery."/".$file)){
header("Cache-control: private");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$file);
header("Content-length: ".filesize($gallery."/".$file)."\n");
//send file contents
$fp=fopen($gallery."/".$file, "r");
fpassthru($fp);
}Hope that helps
I've always done the downloading like in the file (doing a little effort to send the right content type)
http://timvw.madoka.be/programming/php/download.txt
AFAIK there is no problem with file corruption. But, you could always generate an MD5 file so your users can verify it...
http://timvw.madoka.be/programming/php/download.txt
AFAIK there is no problem with file corruption. But, you could always generate an MD5 file so your users can verify it...
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Actually, using SHA256 wouldn't necessarily be a good idea unless you have a large set_time_limit and you're caching the hashes. When you start dealing with message digests of files in the megabytes range, a pure PHP solution is just too slow.
Actually, there's no reason why you shouldn't be caching the hashes. SHA256 will just take a lot longer.
Actually, there's no reason why you shouldn't be caching the hashes. SHA256 will just take a lot longer.