PHP renaming folder problem

Discussion in 'PHP' started by jOE :D, Dec 23, 2007.

  1. #1
    I'm trying to rename a folder from a php file and it's giving me an error. I'm getting a 'Permission Denied' error, but the folder chmod is 777 so I don't understand why I'm getting this error.
     
    jOE :D, Dec 23, 2007 IP
  2. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Can you post your script please.

    it is sure weird, unless you didnt chmod the folder correctly, or the error is in your own script.
     
    DarkMindZ, Dec 23, 2007 IP
  3. jOE :D

    jOE :D Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I know the error is not a syntax error with my code because it's denying permission, not giving me a syntax error.

    Here is the part where I do the actual rename though:
    
    $oldFolder = $config['sitePath'] . $row['videoFolder'];
    $newFolder = $config['sitePath'] . $random;
    		
    rename($oldFolder,$newFolder) or die("Could not rename directory");
    
    PHP:
     
    jOE :D, Dec 23, 2007 IP
  4. clogmoney

    clogmoney Peon

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try echoing out $oldFolder and $newFolder it may not be where you expect it to be... Simple mistake but easily made.

    Look for ownerships of the folder but if they are 777 then I don't see why this would happen. Interestingly a comment on the php manual pages suggests that directorys can't have the final slash on the end or the function does not work correctly.
     
    clogmoney, Dec 23, 2007 IP
  5. DarkMindZ

    DarkMindZ Guest

    Messages:
    175
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Exactly what he said, go over the code like this:

    $oldFolder = $config['sitePath'] . $row['videoFolder'];
    $newFolder = $config['sitePath'] . $random;

    echo $oldFolder . "<-- OLD Folder <br />";
    echo $newFolder . "<-- NEW Folder <br />";

    and check the results, the problem is most likely there...
     
    DarkMindZ, Dec 23, 2007 IP
  6. Vio82

    Vio82 Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Check the owner group of your dir or maybe php_safe_mode is enable...
     
    Vio82, Dec 23, 2007 IP
  7. jOE :D

    jOE :D Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The problem was with the owner/group of the folder. I made a group that included all the possible users that would mod the folder and chgrp'ed to that group. Problem fixed :)
     
    jOE :D, Dec 24, 2007 IP