SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Italy
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    file_put_contents over https

    Hi,I would like to thank anybody who can help me with this problem that I've been wrestling with for weeks now.Whenever I access a page over https and the page uses the imagepng() or the file_put_contents() functions I get the following warning.

    Warning: file_put_contents(cache/top.txt) [function.file-put-contents]: failed to open stream: Permission denied in...

    Is there any way to write files over https? How?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The user which php runs as needs to have write permission to the directory you want to write to. Maybe your web host runs php as a different user when accessed via https, or maybe your confused about where php is really trying to write the file.

    You can see where php is trying to write the file by doing
    PHP Code:
    echo getcwd() . '/cache/top.txt'
    You can see if php runs as a different user by doing
    PHP Code:
    echo getmyuid(); 

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Italy
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi crmalibu,
    Thanks for the quick feedback.

    I tried using getmyuid() and in both cases (http and https) I get 524.
    I'm not sure where this leaves me standing.


    Frodo

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That means the directory you're trying to write to is not writable by that user. This probably means you're trying to write to different directorys.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Italy
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Once again thanks for your support.
    mmmh, but how does it work correctly when I'm over normal http then? I'm not sure I understand.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you suggesting you have actually checked, and the directory is the same?

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Italy
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by crmalibu View Post
    Are you suggesting you have actually checked, and the directory is the same?
    indeed: both over http and https getcwd() gives the same directory

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you get the same results from stat('cache/')? excluding atime

    what is the mode?


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
  •