-
[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
-
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
-
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
-
Thanks kows, that works perfectly.
Mitchel