PHP File Access

nschmoyer

New Member
Hello,

I would like to be able to read a flat file with php (via fopen and fgets), but not allow viewers to access the file itself (by visiting www.website.com/flat_file).

I have not been able to get this working properly with file permissions. Is there another (efficient) way to accomplish this?
 
Check if your web host allows you to store the file in a password protected directory. You can also set up your own password protection with .htaccess if your host allows that. Here is a tutorial.
 

n1c0_ds

New Member
I have nothing to add. DesignerBill has covered the topic and provided the best answer. I merely confirm that using .htaccess is the best solution here.
 

MarkR

New Member
Another solution is to store it outside the web directory. For example store it in the directory above where you put the rest of your website.
 
Top