Aaron Todd wrote:

I have been using the following code to try to make it work:
<?php
$file = /home/site/member/filename.xxx";
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
?>

The webroot of my site is at:  /var/www/html

So far this will create a new file on my computer where ever I want, but it does not download the contents of the file.

Any suggestions?

Thanks,

Aaron


It seems that PHP can't read the file '/home/site/member/filename.xxx', what are the permissions for this file?

PHP's rights are the same as the user Apache runs on. This is usually "httpd" or "apache" in most linux distributions.

In your previous post, you were asking where to best place the file so it is "protected" somehow. You could actually place it in a simpler directory like

/var/www/downloads

then set x bit for the _other_ users of the downloads directory, so PHP can access files under it

chmod o+x downloads

and set all files under this directory to be readable by others (esp PHP)

chmod o+r downloads/*


THis way, PHP can't modify files in this directory. And no one can just download a file by entering a URL (since the files are outside the webserver path).



goodluck!


HTH.



---
ramil

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to