How to Store PDF Files in a Databaseby Cristina Puno
Databases are used to store information for easy lookup and better data management. The usual types of data stored are texts and numbers. Data types such as VAR or VARCHAR will let you store characters or text, while INT and FLOAT will let you store numbers. One data type called a BLOB (binary large object) will enable you to store binary files such as a DOC file, executable files and PDF files. By creating an upload form connected to your database, you can successfully store PDF files in it.
Create a database to hold your PDF file. Create a new table to store a PDF file, with fields for the file name and a field to store the PDF file. Choose the BLOB data type for PDF storage; this will allow you to store binary data such as PDFs in your database.
Create an input form for users to upload the PDF on your database. Using Notepad or an HTML Editing tool such as Dreamweaver or FrontPage, create a form that has an input text field for the file, a "Browse" button for users to choose a PDF to upload and a "Submit" button to upload the file. In the <form> tag, specify a the file name of the upload script that will store the PDF file in your database. Save your form as an HTML file.
Create your upload script. Using a web programming language such as PHP or ASP.net, create a routine for handling the PDF file submitted. The script will have three sections: a database-connection script, a script to capture the data submitted by the form and the SQL that uploads the file in your database. Save your file. Make sure that the name of the file matches the one you indicated in your HTML form.
Upload the form and the script file on your web server.
Access the form and use it to upload your PDF file to the database.
Items you will need
- photo_camera Thomas Northcut/Digital Vision/Getty Images