tutorials.de Buch-Aktion 05/2012
ERLEDIGT
NEIN
ANTWORTEN
2
ZUGRIFFE
707
EMPFEHLEN
  • An Twitter übertragen
  • An Facebook übertragen
AUF DIESES THEMA
ANTWORTEN
  1. #1
    TsEnG TsEnG ist offline Mitglied Silber
    Registriert seit
    Jan 2002
    Beiträge
    58
    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;
    }
    ?>
     

  2. #2
    Registriert seit
    Dec 2002
    Ort
    Trier
    Beiträge
    17.502
    Blog-Einträge
    10
    Hast du den letzen Parameter mal auf „true“ gesetzt, um einen detaillierten Bericht zu bekommen?
     
    Markus Wulftange

  3. #3
    TsEnG TsEnG ist offline Mitglied Silber
    Registriert seit
    Jan 2002
    Beiträge
    58
    ja aber da kommt leider keiner
     

Ähnliche Themen

  1. Inhalt mehrerer Ordner kopieren
    Von MBomber im Forum Microsoft Windows
    Antworten: 3
    Letzter Beitrag: 06.07.10, 11:24
  2. Antworten: 3
    Letzter Beitrag: 13.09.07, 10:13
  3. Ordner Inhalt kopieren?
    Von lordfritte im Forum PHP
    Antworten: 8
    Letzter Beitrag: 12.08.07, 18:47
  4. Ordner mit Inhalt per FTP kopieren?
    Von Matthiasghh im Forum PHP
    Antworten: 2
    Letzter Beitrag: 12.01.06, 02:52
  5. Auf FTP Server mittels PHP kopieren
    Von brainyy im Forum PHP
    Antworten: 5
    Letzter Beitrag: 12.10.05, 10:03