Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    mtd
    mtd is offline
    Regular Coder
    Join Date
    Jun 2003
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fopen() permission error

    Hi. I have a script that uses fopen() to open and make changes to other files on the server. I developed the script, tested it on one server, and it worked great. However, I tried it on another server and I get:

    Warning: fopen(/path/to/file.htm): failed to open stream: Permission denied in /path/to/script.php on line 316

    (Obviously the paths are changed for simplicity/security)

    Is this a problem with my php, or server config? I contacted the host and - after convincing them my code was valid - they told me I had to chmod everything to 666. The thing is, this worked on the first host with no problems at 644. HELP! If this is not a php issue, please point me in the right direction (or you could help anyway, which would be great...)

    Thanks

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    It's not a php issue, but like your host said, a permissions issue. If 0644 doesn't work, then try 0777 (think that one's right)

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's permission issue.
    777 will solve the problem but try to limit cause fopen() don't need write permission

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    fopen may need chmod including write permissions however.
    If 0644 doesn't work for you, attempt a 0700 instead. If neither work for you, you need alternative means for this, as your host doesn't allow the use of file opening via php. Some means may include XML or curl.

  • #5
    mtd
    mtd is offline
    Regular Coder
    Join Date
    Jun 2003
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the suggestions. Two important characteristics of this project:
    1) It is a CMS for a non-technical user (no idea about chmod)
    2) Being a CMS, it will need to access almost all the files on the server (about 200+ so far, and growing)

    That said, is having to chmod every existing file now and every new file in the future really an ideal solution? Can I ask the host to change the owner of the files or something? I would think it would be easy for them to change a server config somehow to allow this, as like I said it works at 644 with another host. I am not that familair with working with hosts, so I don't know if that type of mod is feasible or an acceptable request of them.

    I have heard about curl, but that's about it. I'd have to do some serious reading and probably have to completely revamp my code?

    ARGHHH!

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    chmod can be done at script process. The function chmod() will do the trick for you in this case. If your filepermissions are not a problem, then its a limitation of your host, which means that using an alternative method will be in store. Yes, curl will be an option, and will require alterations for your current methods in order to work.


  •  

    Posting Permissions

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