Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][HTML] Plik do pobrania :P
patryk20120
post
Post #1





Grupa: Zarejestrowani
Postów: 256
Pomógł: 1
Dołączył: 20.04.2008

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


Witam (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
mam taki problem, że aż sam jestem zaszokowany ;p mam jakiś plik *.txt i jak dać odnośnik, tak, aby user mógł go sobie pobrać, bo gdy dam link do tego pliku, to on mi się wyświetla, a nie pobiera (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
sowiq
post
Post #2





Grupa: Zarejestrowani
Postów: 1 890
Pomógł: 339
Dołączył: 14.12.2006
Skąd: Warszawa

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


Pewniejsza jest metoda:

  1. <?php
  2. // $file - plik do pobrania
  3. // $name - domyślna nazwa do zapisania na dysku
  4.  
  5.  
  6. // fix for IE catching or PHP bug issue
  7. header("Pragma: public");
  8. header("Expires: 0"); // set expiration time
  9. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  10. // browser must download file from server instead of cache
  11.  
  12. // force download dialog
  13. header("Content-Type: application/force-download");
  14. header("Content-Type: application/octet-stream");
  15. header("Content-Type: application/download");
  16. header('Content-Disposition: attachment; filename="'.$name.'"');
  17. @readfile($file);
  18. ?>
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: 5.10.2025 - 01:50