I have a php function to perform file downloads, more specifically from certificate files.
<?php
session_start();
if(!isset($_SESSION['user'])) {
// user is not logged in, do something like redirect to login.php
header("Location: ../login.php");
die();
}
$file = basename($_GET['fid']);
$file = '../certs/'.$file;
// Quick check to verify that the file exists
if( !file_exists($file) ) die("File not found");
// Force the download
header("Content-Disposition: attachment; filename=\"".basename($file)."\"");
header("Content-Length: " . filesize($file));
header("Content-Type: application/x-pkcs12;");
readfile($file);
?>
The way I download it normally is as shown below.
<p><a href="download.php?fid=<?= $_SESSION['user'].".p12" ?>" class="button" >Download do certificado pessoal</a></p>
<p><a href="download.php?fid=ca.crt" class="button" >Download da CA</a></p>
I already managed via googleapis chart as test, example, <img src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=teste&choe=UTF-8" />
I would like to put the option to download via qr-code, using my php function, if it were possible.
It would look something like <img src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=download.php?fid=<?= $_SESSION['user'].".p12" ?>&choe=UTF-8" />
with download.php?fid=<?= $_SESSION['user'].".p12" ?>
as content of chl variable.
Or use another qr-code library. Would anyone have any examples or hints how can I accomplish this?