I am working on a small document management system. I have created the function that allows me to upload a document to the database. But now I want to give a user two options, view the document online or download it straight to their PC. I'm currently working on the 'view online' function and I'm struggling. I found a document viewer called 'ViewerJS' but I do not know how to integrate it, I've even followed the instructions. See below for more information:
Website File Directory:
ViewerJS Directory:
Database "Upload" Table:
The first image shows my website file directory, which also happen to be the same files that I uploaded to the database for testing purposes. The second image shows the viewerJS directory, that I downloaded from the internet. And the third image shows my table in the database where my uploaded files are stored. I really am struggling to display what's in the database, in the viewerJS document viewer.. can anyone help? Also see my uploadconfig.php file below:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include("dbconfig.php");
if(isset($_POST['btn-upload'])){
if (empty($_FILES['file']['name'])){
header("location:upload.php?msg0= Please select a file to upload.");
} else {
$loggedinuser = $_GET['bid'];
$file = $_FILES['file']['name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
$sql = mysqli_query($conn, "INSERT INTO upload (personalid, file, type, size) values ((select personalid from person where username='$loggedinuser'), '$file', '$file_type', '$file_size')") or die (mysqli_error($conn));
if($sql){
header("location:upload.php?msg1= Document Uploaded.");
}
else {
header("location:upload.php?msg2=Document Not Uploaded.");
}
}
}
?>
<!-- need to commentt -->