user2773673
user2773673

Reputation: 39

File readable & writable only by server php and not from client

I have some txt files with informations, but this *.txt files is going to be readable and writable by server php, (for example include them or just check them).

but i dont what this files to be accesstable from browser for example the user must can not view the files with http:// mysite/myfile.txt

what perrmission i have to set up for this files when php makes them?

Upvotes: 0

Views: 496

Answers (1)

Elon Than
Elon Than

Reputation: 9765

You can't do that using permissions. In both cases server will read file.

You have to put this file in public parent directory (eg. in directory where is your public_html). This way you'll be still able to include it but noone can read it using browser.

Second option is to set correct .htaccess file to deny all users (it'll still allow you to read it from scripts), eg. like this:

order deny,allow
deny from all

Upvotes: 1

Related Questions