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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts

    I need to copy and rename a file

    I am writing a simple script for a subscriber to create a simple web page.

    I now need to copy and rename a file for use by another user.

    This is the code that I am trying with and can't get it to work:
    PHP Code:
            $old 'fr_addclub.php';
            
    $new 'modify_club.php';
            
    copy($old$new) or die("Unable to copy $old to $new."); 
    This script that is running this is in the same directory as $old and where I want $new.

    This is the response:
    Unable to copy fr_addclub.php to modify_club.php.
    I have tried changing the file to .txt files, but that didn't work (as I expected).
    I have changed file ownership to chmod 600 and chown to apache.apache and that hasn't worked.

    Can anybody suggest what is wrong ??

    Thanks,
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Remove the or die, and add or print_r(error_get_last()); die(); and post that (or simply enable your error reporting).
    If I had to guess, it's safe_mode restricted. Did you verify that the apache.apache is the name of the apache user? Also, is the ownership set on the directory itself?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder
    Join Date
    Nov 2011
    Location
    Preston, UK
    Posts
    131
    Thanks
    36
    Thanked 0 Times in 0 Posts
    Hi Fou-Lu
    Once again you haver come to my rescue.
    You are my knight in shining armour...

    The problem was ownership. The file was owned by apache, but the directory was NOT owned by apache.
    It is now.

    Many thanks for the lead...

    I have a new problem now, but that is for another thread.
    The MAN, The MYTH, The LEGEND:
    John C
    ________________________________
    Support your local Country Music Club


  •  

    Posting Permissions

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