orange77 Posted December 31, 2019 Posted December 31, 2019 Hi, I'm developing a website in PHP. What I need is some mechanism to protect a folder called profilepics from being accessed by any user in the world. There are users' profile pictures there and I don't want them to be seen or downloaded. How can I do this magic? Thanks.
wolstech Posted December 31, 2019 Posted December 31, 2019 Just put a blank index.php in there and users visiting the folder will see a blank page instead of a file listing. They would need to know the full path including filename to see anything. If you actually block access to it with something like htaccess, the users who do need to load those pictures as part of your site will be unable to do so.
orange77 Posted December 31, 2019 Author Posted December 31, 2019 Just put a blank index.php in there and users visiting the folder will see a blank page instead of a file listing. They would need to know the full path including filename to see anything. If you actually block access to it with something like htaccess, the users who do need to load those pictures as part of your site will be unable to do so.That's not a bad idea entirely, but... How can I block this folder access via htaccess? Is it possible?
Flaze Posted December 31, 2019 Posted December 31, 2019 On the profilepics folder, create a file called .htaccess with the content:Require all deniedThe files are still accessible using PHP.
orange77 Posted January 1, 2020 Author Posted January 1, 2020 On the profilepics folder, create a file called .htaccess with the content: Require all deniedThe files are still accessible using PHP. Thanks. This solution has helped a little bit.
Byron Posted January 4, 2020 Posted January 4, 2020 You can password protect any folder you like by logging into cpanel and then right click on a folder and choose "Password Protect" or if you'd like to view your files without using a password you can use htaccess to only allow your ip address using this code: order deny,allow deny from all allow from 100.60.222.111 Where '100.60.222.111' add your ip address.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now