MySQL Forums
Forum List  »  PHP

Re: import PDF files into mySQL
Posted by: Gregory Rafuse
Date: August 25, 2005 01:33PM

Shah,

I would think you could store the PDF file in a BLOB type field within a table, depending on the size of the PDF file. I've done something similar to this a while back for pictures, but found it better to just store a path to a directory which held the picture and the name of the picture. I would think you'd want to do the same with your PDFs because you're already taking up disk space for the PDF and then you'd be adding additional disk overhead by storing the PDF in a BLOB field.

An example of a table structure I would use would be:

CREATE TABLE documents (
idx INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
doc_name VARCHAR(50) DEFAULT NULL,
doc_path VARCHAR(200) DEFAULT NULL
);

I would then set up a directory structure I could reference from within my PHP script relative to here the documents were to be stored. Assuming a Linux OS, a directory like '/var/pdf_docs'. So, an entry into the 'documents' table might be something like:

INSERT INTO documents (doc_name,doc_path) VALUES ('TOC.pdf','/var/pdf_docs');

Then when you're returning values into a PHP script, then concatenate the values together to get an absolute path to the requested document.

It's just been my experience that it is less effort to have a table with names and paths then to actually store something in a BLOB type field.

My $.02.

Greg

Options: ReplyQuote


Subject
Written By
Posted
August 24, 2005 08:52PM
Re: import PDF files into mySQL
August 25, 2005 01:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.