通过二维码下载文件

时间:2018-08-28 13:48:08

标签: php html qr-code

我有一个php函数来执行文件下载,更具体地说是从证书文件下载。

<?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);
?>

我正常下载它的方式如下所示。

<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>

我已经通过googleapis图表进行管理,例如, <img src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=teste&choe=UTF-8" />

如果可能的话,我想使用我的php函数通过qr代码下载选项。

看起来像<img src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=download.php?fid=<?= $_SESSION['user'].".p12" ?>&choe=UTF-8" />,其中download.php?fid=<?= $_SESSION['user'].".p12" ?>是chl变量的内容。

或使用另一个二维码库。会有人举例或提示我该怎么做吗?

0 个答案:

没有答案
相关问题