Move/Delete file in a directory?

Evening all,

I have a script below which reads files in a directory, when it’s done I wish for the file to be moved or copied to a new directory and removed from the current directory. Anyone help?

Thanks



<?
$path	= '/home/*****/write/'; //Directory which I read from
$complete	= '/home/*****/done/'; //Directory which I wish to place into
$dir	= opendir($path);

while (false !== ($file = readdir($dir))) {

foreach ( $lines as $line ) {
  //Process Code for inserting into database
}

//Now want to copy the file i've just processed from 'write' to 'done' AND delete from write DOES not seem to recognise $file?
copy($path.$file, $move.$file) or die("Unable to copy $path.$file to $move.$file");

}

?>


From the php copy page: http://php.net/manual/en/function.copy.php

If you wish to move a file, use the rename() function.

I would add some echos into your code to confirm that all your variables contain what you expect first to try and find the problem.