ERLEDIGT
NEIN
NEIN
ANTWORTEN
2
2
ZUGRIFFE
707
707
EMPFEHLEN
-
Hallo,
ich möchte mittels PHP einen Ordner kopieren, der gefüllt ist. Nun habe ich schon bei google gesucht und auch bei PhP.net einige sachen gefunden. Doch wenn ich z.B. Die sachen von php.net nehme die man unter function list copy findet, wird bei mir lediglich der Ordner erstellt, doch werden keinerlei dateien hineinkopiert. Hat jemand noch eine andere Idee, ohne exec solch einen Ordner zu kopieren?
Folgendes Script habe ich getestet (von php.net):
PHP-Code:
A function that copies contents of source directory to destination directory and sets up file modes.
It may be handy to install the whole site on hosting.
<?php
// copydirr.inc.php
/*
26.07.2005
Author: Anton Makarenko
makarenkoa at ukrpost dot net
webmaster at eufimb dot edu dot ua
*/
function copydirr($fromDir,$toDir,$chmod=0757,$verbose=false)
/*
copies everything from directory $fromDir to directory $toDir
and sets up files mode $chmod
*/
{
//* Check for some errors
$errors=array();
$messages=array();
if (!is_writable($toDir))
$errors[]='target '.$toDir.' is not writable';
if (!is_dir($toDir))
$errors[]='target '.$toDir.' is not a directory';
if (!is_dir($fromDir))
$errors[]='source '.$fromDir.' is not a directory';
if (!empty($errors))
{
if ($verbose)
foreach($errors as $err)
echo '<strong>Error</strong>: '.$err.'<br />';
return false;
}
//*/
$exceptions=array('.','..');
//* Processing
$handle=opendir($fromDir);
while (false!==($item=readdir($handle)))
if (!in_array($item,$exceptions))
{
//* cleanup for trailing slashes in directories destinations
$from=str_replace('//','/',$fromDir.'/'.$item);
$to=str_replace('//','/',$toDir.'/'.$item);
//*/
if (is_file($from))
{
if (@copy($from,$to))
{
chmod($to,$chmod);
touch($to,filemtime($from)); // to track last modified time
$messages[]='File copied from '.$from.' to '.$to;
}
else
$errors[]='cannot copy file from '.$from.' to '.$to;
}
if (is_dir($from))
{
if (@mkdir($to))
{
chmod($to,$chmod);
$messages[]='Directory created: '.$to;
}
else
$errors[]='cannot create directory '.$to;
copydirr($from,$to,$chmod,$verbose);
}
}
closedir($handle);
//*/
//* Output
if ($verbose)
{
foreach($errors as $err)
echo '<strong>Error</strong>: '.$err.'<br />';
foreach($messages as $msg)
echo $msg.'<br />';
}
//*/
return true;
}
?>
-
Hast du den letzen Parameter mal auf „true“ gesetzt, um einen detaillierten Bericht zu bekommen?
Markus Wulftange
-
ja aber da kommt leider keiner
Ähnliche Themen
-
Inhalt mehrerer Ordner kopieren
Von MBomber im Forum Microsoft WindowsAntworten: 3Letzter Beitrag: 06.07.10, 11:24 -
Vom Ordner zum anderen Ordner Kopieren mit php?
Von harderph im Forum PHPAntworten: 3Letzter Beitrag: 13.09.07, 10:13 -
Ordner Inhalt kopieren?
Von lordfritte im Forum PHPAntworten: 8Letzter Beitrag: 12.08.07, 18:47 -
Ordner mit Inhalt per FTP kopieren?
Von Matthiasghh im Forum PHPAntworten: 2Letzter Beitrag: 12.01.06, 02:52 -
Auf FTP Server mittels PHP kopieren
Von brainyy im Forum PHPAntworten: 5Letzter Beitrag: 12.10.05, 10:03





Zitieren
Login






[PHP][Snippet] Array zu XML konvertieren