accessing password protected directories

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

accessing password protected directories

Post by Clukey »

I've password protected a directory in my site, but I want a php script to be able to access it to download a file from it. How can I do this? Here is the download script:

Code: Select all

$fname = "file.mxp";
$fpath = "folders/$fname";
$fsize = filesize($fpath);
$bufsize = 20000;
header("HTTP/1.1 200 OK");
header("Content-Length: $fsize");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=$fname");
header("Content-Transfer-Encoding: binary");
Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP isn't impeded by password protection on directories, in the .htpasswd sense, of the protection as it makes a local, system level request for the data, or should be, rather.
Clukey
Forum Commoner
Posts: 60
Joined: Fri Apr 21, 2006 9:05 pm

Post by Clukey »

Wow, awesome, I didn't realize that. Thanks
Post Reply