125369
125369

Reputation: 3657

Reading PDF files using PHP

I have been new to the PHP development area and I am working on a small project. In one of the requirement, after the user logs in with a unique ID, I need to search a series a PDF's and if the login ID matches with the corresponding PDF file I need to fetch that and display that. I have created the login form and stored the details in the database. (Here the user and the pdf have the same name to make things easy)

Now I have got a couple of questions:

  1. How can I call the PDF files, does it make sense to store them in the database or just put all the pdfs in the folder and call them from there (if so how I can do it).

  2. After getting the pdf, it should be displayed.

Any valuable information regarding this would be really helpful.

Regards Raks

Upvotes: 0

Views: 414

Answers (2)

aBadAssCowboy
aBadAssCowboy

Reputation: 2520

You need not read the pdf for the purpose as you mentioned that to search the pdf among all the files., and just display that.
for this you can directly display the pdf in the browser itself by just redirecting to the address of the pdf file., and the browsers automatically displays the pdf..

Only you need to do is that, searching for the appropriate file., for this you said the login id should match with the pdf name.., you use the function file_get_contents() which returns boolean when used in a if case and check whether pdf with particular name is available and then if available redirect the user, or else tell him that its not available..

Upvotes: 1

Simone
Simone

Reputation: 21282

  1. No, it is useless. Just put all PDFs in a folder.
  2. Link the users to the .pdf file

Upvotes: 1

Related Questions