Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] PILNE Kopiowanie plików z katalogn do innego katalogu
dawhol
post
Post #1





Grupa: Zarejestrowani
Postów: 256
Pomógł: 0
Dołączył: 19.07.2006
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


Witam potrzbuję pilnie skrypt który skopiuje mi pliki z katalogu na serwerze www.costam.pl/katalog/ na serwer www.blebleble.com/katalog2/ (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
ew. ten drugi serwer to moze byc dysk twardy naszego komputera

BYŁ BYM NIEZMIERNIE WDZIĘCZNY za odpowiedz (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) .
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 9)
nasty
post
Post #2





Grupa: Zarejestrowani
Postów: 634
Pomógł: 14
Dołączył: 27.05.2006
Skąd: Berlin

Ostrzeżenie: (0%)
-----


http://php.net/pl/copy
Go to the top of the page
+Quote Post
piotrd
post
Post #3





Grupa: Zarejestrowani
Postów: 174
Pomógł: 0
Dołączył: 16.05.2006
Skąd: Łódź

Ostrzeżenie: (0%)
-----


nie krzycz w poście.
czy chodzi Ci o cos takiego -> http://www.google.pl/search?q=WebFTP (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
dawhol
post
Post #4





Grupa: Zarejestrowani
Postów: 256
Pomógł: 0
Dołączył: 19.07.2006
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


Zalezało by mi na gotowcu (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) wiem ze to forum sluzy do pomocy a nie dawania gotowych skryptół ale to jest pilne a mi napisanie skryptu zajmie troche czasu bo jestem poczatkujacy (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) .

a pozatym chodzi mi to o wszystkie pliki z katalogu (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) lub ew. cały katalog (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post
nasty
post
Post #5





Grupa: Zarejestrowani
Postów: 634
Pomógł: 14
Dołączył: 27.05.2006
Skąd: Berlin

Ostrzeżenie: (0%)
-----


Kod
<?php

  // copy a directory and all subdirectories and files (recursive)
  // void dircpy( str 'source directory', str 'destination directory' [, bool 'overwrite existing files'] )
function dircpy($basePath, $source, $dest, $overwrite = false){
   if(!is_dir($basePath . $dest)) //Lets just make sure our new folder is already created. Alright so its not efficient to check each time... bite me
   mkdir($basePath . $dest);
   if($handle = opendir($basePath . $source)){        // if the folder exploration is sucsessful, continue
       while(false !== ($file = readdir($handle))){ // as long as storing the next file to $file is successful, continue
           if($file != '.' && $file != '..'){
               $path = $source . '/' . $file;
               if(is_file($basePath . $path)){
                   if(!is_file($basePath . $dest . '/' . $file) || $overwrite)
                   if(!@copy($basePath . $path, $basePath . $dest . '/' . $file)){
                       echo '<font color="red">File ('.$path.') could not be copied, likely a permissions problem.</font>';
                   }
               } elseif(is_dir($basePath . $path)){
                   if(!is_dir($basePath . $dest . '/' . $file))
                   mkdir($basePath . $dest . '/' . $file); // make subdirectory before subdirectory is copied
                   dircpy($basePath, $path, $dest . '/' . $file, $overwrite); //recurse!
               }
           }
       }
       closedir($handle);
   }
}

?>

to jest w komentarzach w manualu

Ten post edytował nasty_psycho 30.07.2006, 10:35:00
Go to the top of the page
+Quote Post
dawhol
post
Post #6





Grupa: Zarejestrowani
Postów: 256
Pomógł: 0
Dołączył: 19.07.2006
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


problem w tym ze nieznam loginu adresu ftp i hasla (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) bo ja che poprotsu pobrac tapetki z katalogu na jakims tam serwerze a jest ich tam sporo dltego bym spedzil chyba z 3 godziny jak bym kopiował kazda z osobna.
Go to the top of the page
+Quote Post
nasty
post
Post #7





Grupa: Zarejestrowani
Postów: 634
Pomógł: 14
Dołączył: 27.05.2006
Skąd: Berlin

Ostrzeżenie: (0%)
-----


nio, ale tu nie trzeba miec usera i password, wystarczy katalog z plikami i katalog docelowy
Go to the top of the page
+Quote Post
dawhol
post
Post #8





Grupa: Zarejestrowani
Postów: 256
Pomógł: 0
Dołączył: 19.07.2006
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $source = 'http://i.mota.ru/nature/img/';
  3. $basePath = './tapety/';
  4. // copy a directory and all subdirectories and files (recursive)
  5. // void dircpy( str &apos;source directory&apos;, str &apos;destination directory&apos; [, bool &apos;overwrite existing files&apos;] )
  6. function dircpy($basePath, $source, $dest, $overwrite = false){
  7.  if(!is_dir($basePath . $dest)) //Lets just make sure our new folder is already created. Alright so its not effici
    ent to check each time... bite me
  8.  mkdir($basePath . $dest);
  9.  if($handle = opendir($basePath . $source)){ // if the folder exploration is sucsessful, continue
  10.  while(false !== ($file = readdir($handle))){ // as long as storing the next file to $file is successful, continue
  11.  if($file != &apos;.&apos; && $file != &apos;..&apos;){
  12.  $path = $source . &apos;/&apos; . $file;
  13.  if(is_file($basePath . $path)){
  14.  if(!is_file($basePath . $dest . &apos;/&apos; . $file) || $overwrite)
  15.  if(!@copy($basePath . $path, $basePath . $dest . &apos;/&apos; . $file)){
  16.  echo &apos;<font color="red">File (&apos;.$path.&apos;) could not be copied, likely a permissions problem.</font>&apos;;
  17.  }
  18.  } elseif(is_dir($basePath . $path)){
  19.  if(!is_dir($basePath . $dest . &apos;/&apos; . $file))
  20.  mkdir($basePath . $dest . &apos;/&apos; . $file); // make subdirectory before subdirectory is copied
  21.  dircpy($basePath, $path, $dest . &apos;/&apos; . $file, $overwrite); //recurse!
  22.  }
  23.  }
  24.  }
  25.  closedir($handle);
  26.  }
  27. }
  28.  
  29. ?>


dałem zmienne $basepath i $source ale i tak mi nie dziala wyskakuje blad
  1. <?php
  2. Parse error: parse error, unexpected '&' in /var/www/html/php/index.php on line 11
  3. ?>
Go to the top of the page
+Quote Post
nasty
post
Post #9





Grupa: Zarejestrowani
Postów: 634
Pomógł: 14
Dołączył: 27.05.2006
Skąd: Berlin

Ostrzeżenie: (0%)
-----


skopjuj jeszcze raz kod ktory ci podalem, bo tamto bylo w [php] i rozj***** ciapki, teraz jest ok
pozdrawiam
Go to the top of the page
+Quote Post
dawhol
post
Post #10





Grupa: Zarejestrowani
Postów: 256
Pomógł: 0
Dołączył: 19.07.2006
Skąd: Ostrów Wielkopolski

Ostrzeżenie: (0%)
-----


niewiem moze jestem za ciemny ale nada mi nie dziala jak mozesz to mi napisz jakie mam ustawic zmienne bo nie zabardzo kapuje te komentarze w skrypcie (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

katalog w którym maja sie pojawic pliki u mnie na serwerze to ./tapety/ a katalog z którego maja sie skopiowac pliki to http://i.mota.ru/nature/img/

Prosze bardzo (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) pomóz mi (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) potrzbuje tych tapetek do strony z darmowymi tapetami do komórek i palmtopów (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

nie pokazuje zadnego bledu ale pliki sie nie pojawiaja na dysku (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 05:05