php - Allow users to download PDFs in PHP5, ZEND, MVC environment -


all,

i have php5 application written zend framework , mvc style. application allows multiple users login , see content based on privileges. have dropdown on home page. upon selecting dropdown, ajax call occurs populates page table. also, generates pdf file table data using mpdf library. there link called "download pdf" in page allow user download generated pdf.

my question is, in such environment, how best serve pdfs multiple users? should serve single pdf common name or should create multple pdfs based on dropdown value (looks overkill)? don't want let users see each other's pdfs. also, should store pdfs pretty entire application directory have 750 acccess.

thanks,

  • user clicks "downlod pdf"
  • parameters id sent ajax
  • is there cached version of pdf id saved? ok, show user; else:
    • generate pdf
    • cache it
    • show pdf user

i have cache key userid-documentid (user1-document1 example) , name document make them recognize in "downloads folder": your-app document-name date.pdf (abc half year report 2010-07.pdf example).

i store cache in /tmp directory somewhere, , present cached data custom header; following example 1 @ php.net:

<?php header('content-type: application/pdf');  header('content-disposition: attachment; filename="abc half year report 2010-07.pdf"');  readfile('/tmp/user1-document1'); 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -