note 43579 added to function.copy

From: Date: Sat, 26 Jun 2004 13:00:22 +0000
Subject: note 43579 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-71759@lists.php.net to get a copy of this message
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; } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.copy.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43579 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43579&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43579&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#71759) next »