I am trying to store a reference to a PDF file in MySQL, I then want to load a few files on to a webpage. When I click on the file name I would like the file to load. How do I store the reference in MySQL and access it via PHP?
I have read many posts advising not to add the file directly to MySQL and to just store a reference, but I can't find a tutorial or instructions to guide how to store only a reference/path of the file in MySQL and access via PHP.
<?php
$file = 'BinarySearch.pdf';
$filename = 'BinarySearch.pdf';
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename = "' .$filename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($file);
?>
The above code only opens the file directly stored on the server directly. I am not sure of how to store the path in MySQL. Then on my webpage I want to click a button to retrieve the file. (I have multiple files I want to store.) Thank you so much in advance but I can't find how to do this at all and its integral for my project.