Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Fpdf
Forum PHP.pl > Forum > PHP
slaug
Po kliknięciu na link tworzę za pomocą pliku skrypt.php dokument PDF. I wszystko się robi. Co mam jednak zrobić, aby nie tworzył mi go w oknie przeglądarki, a pojawiało się okienko z wyborem opcji: zapisz, otwórz, anuluj.

Z góry dzięki za pomoc.

pozdrawiam,
Daniel
rogrog
  1. <?php
  2. header('Content-Type: application/octet-stream');
  3. header('Content-Disposition: attachment; filename=nazwapliku.pdf');
  4. header('Content-Type: application/force-download');
  5. //w tym miejscu wysyłanie pliku do przeglądarki
  6. ?>
slaug
Dzięki za odpowiedź.

Później doczytałem manuala FPDF, z którego korzystam a tam oczywiście łatwiutko to zrobić, wystarczy wywołać funkcję output z parametrami nazwa i date:

Kod
$pdf->Output('nazwa.pdf', 'D');


Cytat
string Output([string name [, string dest]])

Description
Send the document to a given destination: string, local file or browser. In the last case, the plug-in may be used (if present) or a download ("Save as" dialog box) may be forced.
The method first calls Close() if necessary to terminate the document.
Parameters
name
The name of the file. If not given, the document will be sent to the browser (destination I) with the name doc.pdf.
dest
Destination where to send the document. It can take one of the following values:
I: send the file inline to the browser. The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.
D: send to the browser and force a file download with the name given by name.
F: save to a local file with the name given by name.
S: return the document as a string. name is ignored.
If the parameter is not specified but a name is given, destination is F. If no parameter is specified at all, destination is I.

Note: for compatibility with previous versions, a boolean value is also accepted (false for F and true for D).


pozdrawiam i jeszcze raz dziękuje za odpowiedź,
Daniel
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.