1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Rep Power
    Hi! I am a "newbie" when it comes to PHP, so this is probably a very easy question but please reply because I have been unable to find the answer.

    Ok, I have a file which I don't want people to access, so I basically used CHMOD and fixed that problem. However, I would like a PHP script to be able to use this file. So, if I run ex. mytest.php and mytest.php includes the line include(myprotectedfile) then it will be able to access it.

    Ok, I've heard a lot about htaccess files, but I don't really know a lot about them. Anyway, this was how I was planning to overcome the problem: OK, mytest.php includes a statement that changes the chmod of myprotectedfile, for example to 777 (or whatever). This is done in the beginning of the script. Now the program can basically access myprotectedfile without any problem. Then, after accessing the file it would now change the CHMOD back to the original value.

    OK, that's how I am planning to do it, but are there easier ways around the problem?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Rep Power
    Hey Al,

    You could place the file outside of your server document root and retrieve it as needed using an include() or require().


    if you want to use .htaccess (in the end much less of a hassle than chmod'ing things around),
    Check this tutorial out: http://www.zend.com/zend/tut/authentication.php

    It should do the trick nicely.


    [This message has been edited by wjgilmore (edited October 11, 2000).]

Similar Threads

  1. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 08:27 AM
  2. Pointer problems opening file *formatted*
    By LAKI in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 06:06 AM
  3. Replies: 1
    Last Post: February 8th, 2004, 01:59 PM
  4. PHP file upload script trouble
    By casbboy in forum PHP Development
    Replies: 9
    Last Post: February 5th, 2004, 07:42 PM
  5. Delete file from browser cache
    By CEO in forum Perl Programming
    Replies: 2
    Last Post: January 12th, 2004, 06:57 AM

IMN logo majestic logo threadwatch logo seochat tools logo