Jump to content

How to protect folder and its child files


Recommended Posts

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.  :unsure:  :rolleyes:  :D

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

You can password protect any folder you like by logging into cpanel and then right click on a folder and choose "Password Protect"

 

password-protect.png?raw=1

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...