Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Ściąganie zdjęć z innego serwera
Fixus
post 11.08.2008, 14:08:31
Post #1





Grupa: Zarejestrowani
Postów: 295
Pomógł: 9
Dołączył: 8.02.2006

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


Witam.
ZaŁóżmy, że mam ścieżkę -> http://www.serwerA.pl/zdjecie.jpg
Mój skrypt znajduje się pod adresem -> http://serwerB.pl/skrypt.php

I tu moje pytanie...czy odpalając skrypt na serwerze B mam możliwość za jego pomocą zapisać zdjęcie z serweru A u siebie ? Co należy do tego wykorzystać? SŁyszaŁem coś, że cURL może mi pomóc, ale nigdy go nie używaŁem i nie mam co do tego pewności.

Pozdro.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
Babcia@Stefa
post 11.08.2008, 20:50:27
Post #2





Grupa: Zarejestrowani
Postów: 654
Pomógł: 17
Dołączył: 19.03.2006
Skąd: z kosmosu ;)

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


Może:
- file_get_contents()" title="Zobacz w manualu PHP" target="_manual, file_put_contents()" title="Zobacz w manualu PHP" target="_manual
- fopen()" title="Zobacz w manualu PHP" target="_manual, fgets()" title="Zobacz w manualu PHP" target="_manual, fwrite()" title="Zobacz w manualu PHP" target="_manual, fclose()" title="Zobacz w manualu PHP" target="_manual
- ftp" title="Zobacz w manualu PHP" target="_manual
- cURL" title="Zobacz w manualu PHP" target="_manual.

@edit
Nie jestem moderatorem, ale dobrze by było gdybyś kliknął "Pomógł" obok postu "mroczek" (Post #3).

Pozdrawiam, Babcia@Stefa

Ten post edytował Babcia@Stefa 12.08.2008, 08:13:22


--------------------
Środowisko testowe (desktop) - Gedit, lighttpd, sftp, rsync, xfce4-terminal, chromium, firefox4 | System: Gentoo ~x86
O'Neill - serwer WWW @ lighttpd, links, nano, rsyncd, sftpd | System: Debian
Go to the top of the page
+Quote Post
mroczek
post 11.08.2008, 21:09:45
Post #3





Grupa: Zarejestrowani
Postów: 18
Pomógł: 4
Dołączył: 13.03.2007

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


  1. <?php
  2. // downloading a file
  3. $filename = 'http://www.tnx.nl/php.jpg';
  4.  
  5. // fix for IE catching or PHP bug issue
  6. header("Pragma: public");
  7. header("Expires: 0"); // set expiration time
  8. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  9. // browser must download file from server instead of cache
  10.  
  11. // force download dialog
  12. header("Content-Type: application/force-download");
  13. header("Content-Type: application/octet-stream");
  14. header("Content-Type: application/download");
  15.  
  16. // use the Content-Disposition header to supply a recommended filename and
  17. // force the browser to display the save dialog.
  18. header("Content-Disposition: attachment; filename=".basename($filename).";");
  19.  
  20. /*
  21. The Content-transfer-encoding header should be binary, since the file will be read
  22. directly from the disk and the raw bytes passed to the downloading computer.
  23. The Content-length header is useful to set for downloads. The browser will be able to
  24. show a progress meter as a file downloads. The content-lenght can be determines by
  25. filesize function returns the size of a file.
  26. */
  27. header("Content-Transfer-Encoding: binary");
  28. header("Content-Length: ".filesize($filename));
  29.  
  30. @readfile($filename);
  31. exit(0);
  32. ?>


Wystarczy wstawić link do pliku w zmiennej $filename. Wszystko co jest potrzebne znajdziesz w php.net. Szukałeś?

Ten post edytował mroczek 11.08.2008, 21:10:40


--------------------
spaceofcode.blogspot.com
"Wszyscy wiedzą, że czegoś nie da się zrobić, aż znajduje się taki jeden, który nie wie, że się nie da, i on to robi."
- Albert Einstein
Go to the top of the page
+Quote Post
Fixus
post 27.08.2008, 11:21:28
Post #4





Grupa: Zarejestrowani
Postów: 295
Pomógł: 9
Dołączył: 8.02.2006

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


prawie o to chodziŁo. niestety ja potrzebuje żeby to się zapisywaŁo automatycznie u mnie na serwerze, a nie po zapytaniu na dysk lokalny. Bo muszę ściągnąć 100 plików raz w tygodniu a nie będę siedziaŁ i klikaŁ non stop
Go to the top of the page
+Quote Post
Speedy
post 27.08.2008, 13:07:59
Post #5





Grupa: Zarejestrowani
Postów: 651
Pomógł: 28
Dołączył: 4.12.2004

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


Nie określiłeś w pierwszym poście, o co Ci chodzi. Określenie "u siebie" nie jest jednoznaczne. Widocznie mroczek uznał, że "u siebie", to Twój dysk lokalny.
Jeśli chodzi o to, co napisałeś w ostatnim poście, to kod może wyglądać chociażby tak:

  1. <?php
  2.  
  3. $fileName = 'http://forum.php.pl/style_images/1/logo4.gif';
  4. file_put_contents(basename($fileName), file_get_contents($fileName));
  5.  
  6. ?>


Ten post edytował Speedy 27.08.2008, 13:08:23


--------------------
Sygnatura niezgodna z regulaminem.
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 15:33