note 76400 modified in function.copy by danbrown

From: Date: Mon, 02 Mar 2009 17:53:07 +0000
Subject: note 76400 modified in function.copy by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151355@lists.php.net to get a copy of this message
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 ?> --was-- here is a a function to move a file clean and safe: 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 http://php.net/manual/en/function.copy.php

« previous php.notes (#151355) next »