Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Pobieranie pliku za pomocą PHP
mishka49
post
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 15.07.2013

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


Witam znalazłem taki kawałek kodu
  1.  
  2. $url = 'http://strona.pl/plik.zip';
  3. $file = basename($url);
  4.  
  5. $fp = fopen($file, 'w');
  6.  
  7. $ch = curl_init($url);
  8. curl_setopt($ch, CURLOPT_FILE, $fp);
  9.  
  10. $data = curl_exec($ch);
  11.  
  12. curl_close($ch);
  13. fclose($fp);
  14.  
  15. header('Content-Description: File Transfer');
  16. header('Content-Type: application/octet-stream');
  17. header('Content-Disposition: attachment; filename='.basename($file));
  18. header('Content-Transfer-Encoding: binary');
  19. header('Expires: 0');
  20. header('Cache-Control: must-revalidate');
  21. header('Pragma: public');
  22. header('Content-Length: ' . filesize($file));
  23. readfile($file);

ale plik zamiast zostać pobrany jest wyświetlany w przeglądarce, co może być tego przyczyną?

Ten post edytował mishka49 22.10.2013, 19:08:38
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 20.08.2025 - 13:20