note 76400 deleted from function.copy by aidan

From: Date: Wed, 15 Apr 2009 12:24:18 +0000
Subject: note 76400 deleted from function.copy by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153294@lists.php.net to get a copy of this message
Note Submitter: Flo (somekindofitem.com) ---- here is a a function to move a file clean and safe: <?php function file_move ($quelle, $ziel) { // kopiert datei und loescht sie danach $fertigverschoben = 4; if (file_exists($quelle)) { $fertigverschoben--; if (!file_exists($ziel)) { $fertigverschoben--; if (copy ($quelle, $ziel)) { $fertigverschoben--; if (unlink ($quelle)) $fertigverschoben--; else unlink ($ziel); } } } return $fertigverschoben; // gibt errorcode zurueck, // 0 = alles okay, // 1 = konnte quelle nicht loeschen, // 2 = konnte ziel nicht erstellen (copy), // 3 = ziel existiert bereits, // 4 = quelle nicht gefunden }// ende file_move ?>

« previous php.notes (#153294) next »