Reputation: 11
I have a php script called "upload.php" it has a couple of files that it needs to work. I don't want people to be able to access those files it needs by typing the filename in URL. What do I do to make it possible for upload.php to access those outside of the public folder?
I guess it would be possible to put it all outside of the public folder and make a upload.html file to point to the upload.php? If yes, how to do that?
Upvotes: 1
Views: 2835
Reputation: 14921
You can also put those php files in a folder, let's say "includes" and set a .htaccess file in it:
<Limit GET POST PUT>
order deny,allow
deny from all
allow from 127.0.0.1
</Limit>
Upvotes: 0
Reputation: 218808
Yes, if you don't want people to access those files from outside the server then the best thing to do is to keep them outside of the public folder, elsewhere on the server's file system. PHP, being interpreted server-side, will still be able to access the files (assuming the permissions are correct).
How you would access them depends on how "it needs to work" in your code. Assuming for a moment that the files in question are PHP files which need to be included, include and require both take server-side paths and can reference any file on the server's file system.
Something like this:
include '/full/path/to/file.php';
Upvotes: 2