Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [cURL]Pobieranie wielu plików z ftp
santalam
post
Post #1





Grupa: Zarejestrowani
Postów: 14
Pomógł: 0
Dołączył: 23.04.2005

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


Witam,
mam pytanie odnośnie pobierania przez FTP wielu plików za pomocą cURL.

  1. <?php
  2. function pobierz_foto($local_file, $server_file) {
  3. $c = curl_init();
  4. $file = fopen("$local_file", "wb") or die("Error.\n");
  5. curl_setopt($c, CURLOPT_URL, "ftp://serwer.com/".$server_file);
  6. curl_setopt($c, CURLOPT_FILE, $file);
  7. curl_setopt($c, CURLOPT_BINARYTRANSFER, 1);
  8. curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
  9. curl_setopt($c, CURLOPT_VERBOSE, 1);
  10. curl_setopt($c, CURLOPT_NOPROGRESS, 0);
  11. curl_setopt($c, CURLOPT_FAILONERROR, 1);
  12. curl_setopt($c, CURLOPT_FTP_USE_EPRT, 1);
  13. curl_setopt($c, CURLOPT_FTP_USE_EPSV, 1);
  14. curl_setopt($c, CURLOPT_FTPASCII, 0);
  15. curl_exec($c);
  16.  
  17. curl_close($c);
  18. fclose($file);
  19.  
  20. if(filesize($local_file) <= "500") {
  21. unlink($local_file);
  22. }
  23. }
  24.  
  25.  
  26.  
  27. foreach($files as $file) {
  28. if(!file_exists($file[1])) {
  29. pobierz_foto($file[1], $file[0]);
  30. }
  31. }
  32. ?>


Czy dla każdego pliku muszę powtarzać całą procedurę w funkcji pobierz_foto?
Da się to jakoś usprawnić?
Zależy mi na czasie pobierania zdjęć, a nawiązywanie połączenia z FTP jest dość czasochłonne.

nikt nie wie? (IMG:http://forum.php.pl/style_emoticons/default/sadsmiley02.gif)

Ten post edytował santalam 31.03.2008, 01:58:25
Go to the top of the page
+Quote Post

Posty w temacie


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: 22.08.2025 - 15:52