Upload file pdf php mysql
We will upload multiple records to the database and display all the records from the database on the same page. Show In this article, we will see how we can upload PDF files to a MySQL database using PHP. Approach: Make sure you have XAMPP or WAMP installed on your machine. In this tutorial, we will be using the WAMP server. Creating Database and Table: First, we will create a database named ‘geeksforgeeks’. You can use your existing database or create a new one. Create a table named ‘pdf_data‘ with 3 columns to store the data. Refer to the following screenshot for table structure. table structure Copy and paste the following code into the SQL panel of your PHPMyAdmin. CREATE TABLE IF NOT EXISTS `pdf_data` ( `id` int(50) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `filename` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; We will be using Bootstrap to use Bootstrap’s Responsive Grid System. Below is the code to include the Bootstrap CDN link in the head section of the HTML code.
PHP
Creating folder and files: We will now create a folder named “pdf“. The files uploaded by the client on the server will be stored in this folder. Create index.php and style.css. Keep your main project folder (For example.. GeeksForGeeks) in the “C://wamp64/www/“, if you are using WAMP or “C://xampp/htdocs/” folder if you are using the XAMPP server respectively. The folder structure should look like below: folder structure Creating form: With the HTML form, we are collecting the data from the user by enabling the .pdf file attachment to upload. HTML Form HTML code snippet: Below is the HTML source code for the HTML form. In the HTML |