Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 529983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:08:55+00:00 2026-05-13T09:08:55+00:00

i have a form which allows the user to upload some files to a

  • 0

i have a form which allows the user to upload some files to a folder.

i’ve edit the .htaccess file in that directory to protect this folder from allowing the unwanted visitors to download the contents manually by typing the full url
ex:
http://www.bkabkabka.com/a/b/c/document.pdf

and this is the .htaccess data

Options All -Indexes
<FilesMatch "\.(htaccess|doc|pdf|docx)$">
 Order Allow,Deny
 Deny from all

i have another administration page which allows the responsible guy from our side to download the files by filtering them to anything he want and then click on a html link to normally download the files.
ex:

id             name          filename
1             aaaaa     -->  filename1   <-- this is href link which contains for example http://www.bkabkabka.com/a/b/c/2.doc

the problem is that the htaccess modification is applying globaly and i want to create like a username and password to this folder and then use PHP code to connect to this folder and be able to download the files normally.

how can i do that?

thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:08:55+00:00Added an answer on May 13, 2026 at 9:08 am

    the easiest way to password protect a directory with apache is htpasswd:

    add to your .htaccess in the root dir of the protected directory tree:

    AuthUserFile /home/user/www/protected/.htpasswd
    AuthType Basic
    AuthName "Protected"
    Require valid-user
    

    then run this from the comand line and enter the desired password:

    htpasswd -c /home/user/www/protected/.htpasswd user
    

    you can add another user like so:

    htpasswd /home/user/www/protected/.htpasswd user2
    

    to download files in this protected dir with php, use basic authentication. that is construct a url like so: http://user:password@server/protected/file.txt

    re your comment, in cpanel there’s a “Password Protect Directories” feature accessible from the main page. Here’s some detail on that:

    http://www.siteground.com/tutorials/cpanel/pass_protected_directories.htm

    if you’re planning to store the uploaded files in your protected directory, you would just want to make sure move_uploaded_file copies the file to the right path, e.g.:

    move_uploaded_file($tmpPath, "/home/user/www/protected/$name");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a micropost form which allows a user to upload a photo and
I have a form which allows my user to edit the information as required.
I have a template which allows the user to edit their user information. <form
I have a HTML form which allows a user to add rows ad hoc
I have a file upload function in my asp.net mvc application that allows users
I have a php form which allows the user to provide a reference number
I have the following form which allows a user to select dates/rooms for a
Hopefully easy question, I have a desktop application that allows the user to upload
I have a form which has two inputs. The first input allows a user
I have a mini form on the home page which allows the user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.