Results 1 to 4 of 4

Thread: how do i password protect files on web page

  1. #1
    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.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    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.

  3. #3
    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.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    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.

Similar Threads

  1. Replies: 1
    Last Post: 01-10-2011, 11:44 PM
  2. How do I password protect my files and folders in Windows
    By Altair Creed in forum Technology & Internet
    Replies: 7
    Last Post: 05-04-2010, 04:31 PM
  3. How to protect password?
    By Otilio in forum Windows Software
    Replies: 3
    Last Post: 21-11-2009, 05:12 PM
  4. How to protect text files with password?
    By Level8 in forum Operating Systems
    Replies: 3
    Last Post: 20-11-2009, 12:09 PM
  5. How to create password protect RAR files
    By TechBook in forum Windows Software
    Replies: 2
    Last Post: 06-03-2009, 03:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,866,106.22537 seconds with 17 queries