Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Ściąganie zdjęć z innego serwera
Fixus
post
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
mroczek
post
Post #2





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
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: 3.10.2025 - 19:21