Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z zapisem do pliku TXT
mihow
post
Post #1





Grupa: Zarejestrowani
Postów: 68
Pomógł: 0
Dołączył: 15.09.2003
Skąd: Polska / Płock

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


Cześć!
Mam coś takiego:

  1. <?
  2. $tresc="blalalala";
  3.  
  4. $filecontent=$tresc;
  5.  
  6. header('Content-Type: application/x-unknown');
  7. header('Content-Disposition: attachment; filename="downloaded.txt"');
  8. header('Content-Length: '.strlen($filecontent));
  9. echo $filecontent;
  10. ?>


Niestety przeglądarka nie chce zapisać tego pliku jako "dowbloaded.txt" ale jako "test.php?download=1".
Co robię źle?

Michał
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
devnul
post
Post #2





Grupa: Zarejestrowani
Postów: 1 470
Pomógł: 75
Dołączył: 21.09.2005
Skąd: że znowu

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


  1. <?php
  2. header('HTTP/1.1 200 OK');
  3. header('Date: ' . date("D M j G:i:s T Y"));
  4. header('Last-Modified: ' . date("D M j G:i:s T Y"));
  5. header("Content-Type: application/force-download"); 
  6. header("Content-Lenght: " . (string)(filesize($filelocation)));
  7. header("Content-Transfer-Encoding: Binary"); 
  8. header("Content-Disposition: attachment; filename=".str_replace(" ", "",basename($filelocation)).""); 
  9. readfile($filelocation);
  10. ?>


może tak?
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: 24.08.2025 - 02:16