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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts

    fopen()failed to open stream: Permission denied >> after moving to Linux

    I have this fopen() script that ran fine on Windows, but now on Linux it give me a "Permission denied" error.

    The data.zip file does not exist and should be created with fopen()

    Any ideas?


    PHP Code:
    $fp fopen('data.zip''w'); // << error is on this line
    fwrite($fp$inhalt);
    fclose($fp);

    $zip = new ZipArchive;
    $res $zip->open('data.zip');
    if (
    $res === TRUE) {
        
                
    $path getcwd() . "/test/";
            
    $path str_replace("\\","/",$path); 
            
    mkdir($path0777);
            
        
    $zip->extractTo($path);
        
    $zip->close(); } 
    Last edited by fail; 11-05-2010 at 01:35 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Any ideas?
    Check the permission settings of that directory and make sure that the write permission is there.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    fail (11-05-2010)

  • #3
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    Also check ownership of this folder. Must be available to write for www-data
    to set ownership for folder run
    Code:
    chown -hR root:www-data /folder_name
    and set writeable by groups
    Last edited by poyzn; 11-05-2010 at 01:17 PM.

  • #4
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I got it done by changing the directories to 0777

    Thanks!

  • #5
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Unless the httpd daemon is running as a different user to both the owner:group for the directories, you'd be better going to 0770 maximum. You've given full access to any user with the 0777.


  •  

    Posting Permissions

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