JFile/copy
Aus Joomla! Dokumentation
< JFile(Weitergeleitet von Joomla! Programmierung/Framework/JFile/copy)
JFile/copy Kopiert eine Datei.
Ist der FTP LayerToDo link aktiv, so wird dieser genutzt.
Inhaltsverzeichnis |
[Bearbeiten] Syntax
static copy( $src, $dest, [$path] )
static copy( $src, $dest, [$path], [$use_streams] )
[Bearbeiten] Beispiel
[Bearbeiten] Eine Datei kopieren
if( JFile::copy('pfad'.DS.'zur'.DS.'quelle.php', 'pfad'.DS.'zum'.DS.'ziel.php', JPATH_ROOT) ) { echo 'Die Datei wurde kopiert'; }
Bei einem Fehler während der Ausführung der Funktion wird eine JError::raiseWarning Fehlermeldung ausgegeben
[Bearbeiten] Siehe auch
- JFile->copy() auf api.joomla.org
[Bearbeiten] Quellcode
{ // Prepend a base path if it exists if ($path) { } // Check src path { return false; } if ($use_streams) { if (!$stream->copy($src, $dest)) { return false; } return true; } else { // Initialise variables. if ($FTPOptions['enabled'] == 1) { // Connect the FTP client jimport('joomla.client.ftp'); $ftp = JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); // If the parent folder doesn't exist we must create it { jimport('joomla.filesystem.folder'); } // Translate the destination path for the FTP account if (!$ftp->store($src, $dest)) { // FTP connector throws an error return false; } $ret = true; } else { { return false; } $ret = true; } return $ret; } }