Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to upload pdf file using php

//Form 
<form method="post" action="db_connect.php" role="form" enctype="multipart/form-data"> 
	<input type="file" name="pdf_file" id="pdf_file" accept="application/pdf" />
	<button id="send" type="submit" name="submit" class="btn btn-success">Submit</button>
</form>
//create a file db_connect.php
/// create connection to your database using your localhost server, username, password
 // the name of your database

<?php

$allowedExts = array("pdf");
$temp = explode(".", $_FILES["pdf_file"]["name"]);
$extension = end($temp);
$upload_pdf=$_FILES["pdf_file"]["name"];
move_uploaded_file($_FILES["pdf_file"]["tmp_name"],"uploads/pdf/" . $_FILES["pdf_file"]["name"]);
$sql=mysqli_query($con,"INSERT INTO `Table Name`(`pdf_file`)VALUES($upload_pdf')");
if($sql){
	echo "Data Submit Successful";
}
else{
	echo "Data Submit Error!!";
}
?>
 
PREVIOUS NEXT
Tagged: #upload #pdf #file #php
ADD COMMENT
Topic
Name
9+8 =