Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 05-11-2009
Member
 
Join Date: Oct 2009
Posts: 27
how do i password protect files on web page

I am making a small project on php and want some help in it. How do i exactly password protect the files i upload. I mean i want to upload some content and want it to be accessible to users of the site, but they should not be able to download if they are not registered, that is they must have password to download.
Reply With Quote
  #2  
Old 05-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: how do i password protect files on web page

On click to download the file, direct it to a function which will check for password. The function should look somewhat like this;
Code:
function check(){
var realPassword = 'check';
var password = prompt('Enter the password','');

if(password !=' ' && password !=null)
{
  if(password != realPassword)
  {
		alert("Download not accessible");
  }
}
else{
	alert("Enter the password");
        return false;
      }
}
You may still have to do some work on this, but it might just prevent the user from downloading, if password is wrong. Post if you still have any querry.

Last edited by MindSpace : 05-11-2009 at 10:59 AM.
Reply With Quote
  #3  
Old 05-11-2009
Member
 
Join Date: Oct 2009
Posts: 27
Re: how do i password protect files on web page

well i tried doing what you said, with the html redirect to a page with a validation check by the code you gave, but this is not much help. I am wondering,. is there any way by which i could just password protect my file itself?

Last edited by AARON Carter : 05-11-2009 at 11:06 AM.
Reply With Quote
  #4  
Old 05-11-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: how do i password protect files on web page

I was thinking of just that, so to password protect the file itself, what you can do is use the .htaccess. First make a file named htpasswd and store the username and password there like this; username:12querry34. Keep this file in the folder that is accesible on web. Now make a htaccess file which will be something like this;
Code:
AuthUserFile /usr/local/safe/protect/.htpasswd
AuthGroupFile /dev/null
AuthName PasswordProtect
AuthType Basic
require user username
In the first line give the directory location of the htpasswd file, and the last line give the users you want to give access.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "how do i password protect files on web page"
Thread Thread Starter Forum Replies Last Post
Password protect files/folders on android and computer TomHi Tips & Tweaks 1 01-10-2011 11:44 PM
How do I password protect my files and folders in Windows Altair Creed Technology & Internet 7 05-04-2010 04:31 PM
How to protect password? Otilio Windows Software 3 21-11-2009 05:12 PM
How to protect text files with password? Level8 Operating Systems 3 20-11-2009 12:09 PM
How to create password protect RAR files TechBook Windows Software 2 06-03-2009 03:14 PM


All times are GMT +5.5. The time now is 08:10 PM.