|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
freebeart Smarty n00b
Joined: 11 Oct 2012 Posts: 3
|
Posted: Thu Oct 11, 2012 8:59 pm Post subject: Creating download pdf file |
|
|
Hello,
Please help,
I want to be able open or download file of my Smarty output.
I want to be able to have that download/open directly to the user's computer as a .pdf file.
Any ideas?
This function did not work for me. Bad file is opened.
public function DisplayTac()
{
header('Content-disposition: attachment; filename="documents/tac.pdf"');
header('Content-type: "application/pdf"; charset="utf8"');
}
my paths are:
/smarty/templates/
and
/documents/tac.pdf
Thank you |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Oct 12, 2012 3:46 pm Post subject: |
|
|
Don't you need to send the file as well as headers?
Code: | header('Content-disposition: attachment; filename="documents/tac.pdf"');
header('Content-type: "application/pdf"; charset="utf8"');
readfile(documents/tac.pdf); |
|
|
Back to top |
|
freebeart Smarty n00b
Joined: 11 Oct 2012 Posts: 3
|
Posted: Fri Oct 12, 2012 4:28 pm Post subject: |
|
|
mohrt wrote: | Don't you need to send the file as well as headers?
Code: | header('Content-disposition: attachment; filename="documents/tac.pdf"');
header('Content-type: "application/pdf"; charset="utf8"');
readfile(documents/tac.pdf); |
|
Hi, thanks for replay.
But this did not work.
File is downloaded but, bad size. And Foxit reader pops up.
"Format error. not PDF od corrupted".
Any other ideas?
I can not find the solution.
Thank you very much |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Oct 12, 2012 4:36 pm Post subject: |
|
|
google php download files, see appropriate headers. this isn't something smarty needs to address too, btw. |
|
Back to top |
|
freebeart Smarty n00b
Joined: 11 Oct 2012 Posts: 3
|
Posted: Fri Oct 12, 2012 5:07 pm Post subject: |
|
|
mohrt wrote: | google php download files, see appropriate headers. this isn't something smarty needs to address too, btw. |
Ok. thank you |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|