Results 1 to 4 of 4

Thread: [Resolved] Move File

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    100

    [Resolved] Move File

    Hello,

    This is probably a stupid question, but does anyone know how to move a file on the same system as the php script is running?

    The problem I run into is I have only found a way to do this by using the copy command and then deleting the old file (unlink) this however resets all the attributes on the file..creation time..modification time..accessed time.. Which I happen to need to keep!

    Thanks guys,
    Mitchel
    Last edited by toto; Sep 8th, 2003 at 08:24 PM.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    I think you're looking to rename() the file.

    Something like this:

    PHP Code:
    <?
      rename(
             "c:/web/file.txt", //old file
             "c:/web/dir/dir/file.txt" //new file
            );
    ?>
    I can't say I know if it keeps the file attributes or not, but I'm sure you could try it out and find that out for yourself. Here's the PHP.net full coverage:

    http://ca.php.net/manual/en/function.rename.php
    Last edited by kows; Sep 8th, 2003 at 06:25 PM.
    Like Archer? Check out some Sterling Archer quotes.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    100
    Cool, Thanks, I'm going to try that as soon as I have a minute, I'll get back and let you all know if it works.

    Mitchel

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Posts
    100
    Thanks kows, that works perfectly.

    Mitchel

Posting Permissions

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



Click Here to Expand Forum to Full Width