Results 1 to 8 of 8

Thread: Access protected directory

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Access protected directory

    I need to be able to protect a directory so that only my PHP script can access it. (I have files in there that I don't want to have downloaded unless I know about it.)

    How can I give my PHP script the username and password to access this file?

    or would it be better if I did an FTP sort of thing? How would I do this?

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Re: Access protected directory

    This might be what your looking for... Direct from the php manual

    http://us2.php.net/features.http-auth

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Re: Access protected directory

    I'm not wanting to protect a file that I'm creating... I'm wanting to access a directory that is already protected in order to download files... I don't want my user to be able to go in and download files directly from the directory without my script.

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  4. #4
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770

    Re: Access protected directory

    Maybe there is something on this page that can help you

    http://www.php.net/manual/en/ref.filesystem.php

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Access protected directory

    Are you using Apache? If so, create a file called .htaccess in the directory you want to protect and add the following lines:
    Code:
    Order allow,deny
    Deny from all
    You want to add a username an password. How do you want to implement this? Do you want to enable access by multiple users and passwords or just protect the script with a generic password?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Re: Access protected directory

    I just want to put in a password that no one knows about except for me and be able to pass that username and password to the webserver from my php script instead of asking the user for it...

    squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Access protected directory

    The PHP script wouldn't need the password, unless it for some reason uses HTTP to access those files.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Re: Access protected directory

    Well, how I was having it work was to use something like

    <header "Location: http://www.whatever.com/file.ext">

    to download the file...

    Is there a way to do this that wouldn't require redirection?

    Thanks,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width