|
-
Sep 8th, 2003, 04:51 PM
#1
Thread Starter
Lively Member
[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.
-
Sep 8th, 2003, 06:22 PM
#2
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.
-
Sep 8th, 2003, 07:24 PM
#3
Thread Starter
Lively Member
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
-
Sep 8th, 2003, 08:25 PM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|