October 10th, 2000, 04:49 AM
Hi! I am a "newbie" when it comes to PHP, so this is probably a very easy question but please reply because I have been unable to find the answer.
Ok, I have a file which I don't want people to access, so I basically used CHMOD and fixed that problem. However, I would like a PHP script to be able to use this file. So, if I run ex. mytest.php and mytest.php includes the line include(myprotectedfile) then it will be able to access it.
Ok, I've heard a lot about htaccess files, but I don't really know a lot about them. Anyway, this was how I was planning to overcome the problem: OK, mytest.php includes a statement that changes the chmod of myprotectedfile, for example to 777 (or whatever). This is done in the beginning of the script. Now the program can basically access myprotectedfile without any problem. Then, after accessing the file it would now change the CHMOD back to the original value.
OK, that's how I am planning to do it, but are there easier ways around the problem?
October 11th, 2000, 02:40 AM
You could place the file outside of your server document root and retrieve it as needed using an include() or require().
if you want to use .htaccess (in the end much less of a hassle than chmod'ing things around),
Check this tutorial out: http://www.zend.com/zend/tut/authentication.php
It should do the trick nicely.
[This message has been edited by wjgilmore (edited October 11, 2000).]