note 43579 deleted from function.copy by tomsommer

From: Date: Wed, 21 Jul 2004 16:04:04 +0000
Subject: note 43579 deleted from function.copy by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73816@lists.php.net to get a copy of this message
Note Submitter: tompittlik@csbanana.com ---- To move a file rather than copy it, simply copy it then unlink the source file... <? function movefiles($source_dir, $destination_dir, $array_of_files) { $i = 0; while ($i < count($array_of_files)) { if (is_dir($source_dir . $array_of_files[$i])) { $object = "Folder " . $array_of_files[$i]; } else { $object = "File " . $array_of_files[$i]; } if (!@copy($source_dir . $array_of_files[$i], $destination_dir . $array_of_files[$i])) { echo "$object couldn't be moved.<br/>\n"; } else { if (!@unlink($source_dir . $array_of_files[$i])) { // if source can't be removed, remove copied file unlink($destination_dir . $array_of_files[$i]); echo "$object couldn't be moved.<br/>\n"; } else { echo "$object moved successfully.<br/>\n"; } } ++$i; } } ?>

« previous php.notes (#73816) next »