Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> zapis pliku na dysk, pdf-y, grafika, itp
kari
post
Post #1





Grupa: Zarejestrowani
Postów: 52
Pomógł: 0
Dołączył: 1.03.2005

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


mam na stronie Ink prowadzący do pliku *.pdf.
w jaki sposób, poprze pojedyncze klikniecie zmusić przeglądarkę, do zapisania tego pliku na dysku, zamiast go otwierać.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
hwao
post
Post #2


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




  1. <?php
  2. if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match(&#092;"/MSIE/\", $_SERVER['HTTP_USER_AGENT'])) {
  3.  // IE Bug in download name workaround
  4.  ini_set( 'zlib.output_compression','Off' );
  5.  }
  6.  header( 'Content-Type: application/octet-stream' );
  7.  header( Content-Size: $fileSize );
  8.  header( &#092;"Content-Disposition: attachment; filename=\"$fileName\"\");
  9.  @readfile($filepath);
  10. ?>

  1. <?php
  2.  //Begin writing headers
  3.  header(&#092;"Pragma: public\");
  4.  header(&#092;"Expires: 0\");
  5.  header(&#092;"Cache-Control: must-revalidate, post-check=0, pre-check=0\");
  6.  header(&#092;"Cache-Control: public\");
  7.  header(&#092;"Content-Description: File Transfer\");
  8.  
  9.  //Use the switch-generated Content-Type
  10.  header(&#092;"Content-Type: $ctype\");
  11.  
  12.  //Force the download
  13.  $header=&#092;"Content-Disposition: attachment; filename=\".$filename.\";\";
  14.  header($header );
  15.  header(&#092;"Content-Transfer-Encoding: binary\");
  16.  header(&#092;"Content-Length: \".$len);
  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: 27.12.2025 - 15:07