View Full Version : Write/Move/Save pdf to MySQL Table?

07-12-2006, 11:01 PM
Is upload the only way to pass a file to a table?

I have a contract.pdf which is generated via php (FPDF) and saved in a temporary file. I need that file then moved /written to the appropriate customer table in our database (MySQL ) so that the temporary file may then be overwritten by the next Customer/Order.

While I am able to upload the file via <input type="file" name="uploadpdf> and related uploader.php, asking our web-users to “browse” for the file does not suit our needs, and of course adding a default value
<input type="file" name="uploadpdf" value="http://localhost/crm/modules/Orders/contract.pdf"> doesn’t work either.

As the file is always the same (modules/Orders/contract.pdf) how may I manage that move automatically, (say with a ‘Confirm Order’ button) to the database?

07-13-2006, 11:07 AM
your post doesn't make a lott of sense to me.

what you normally do is store the file in some directory, and then you only store the path to the file inside your db.
if you then want to show all the files that were generated for that user, then you just run a select on your table, and you display a link to each file (using the path from the db inside the link-tag).
so when you create the pdf on your server, you give it some unique name, like username_date_time.pdf, and then you store the path in your db. if you only want to keep 1 file for each user, then just always name the file like username.pdf.
if you upload the file from the users local, then you rename the file and move it from the temporarely directory to wherevere you want to store the files, and then again store the path in your db.

07-14-2006, 07:21 PM
Please see this article about BLOBS.


I've done this in Oracle without much trouble, and MySQL is usually easier.