我是PHP编程的新手。所以我有一个很大的问题:
我的问题是我会有一个按钮,例如:
<a href="/upload_crypt.php?id=370&snrid=123456">PDF Download</a>
我将使用此upload_crypt.php文件来获取我的完整链接。必须将此链接设置为标头请求,以便用户无法看到完整路径,并且浏览器会将pdf显示为安全。
在我的upload_crypt.php文件中,我有以下代码:
<?php
include_once("db.inc.php");
include_once("db_connect.inc.php");
@session_start();
$snrid = $_GET['snrid'];
$id = $_GET['id'];
$sql_query4 = 'SELECT * FROM web_osc_uploads WHERE Section = "Schaden" AND DocType = "pdf" AND DocDesc = "Kaufbeleg" AND IdentValue = "'.$_GET['snrid'].'" AND ID = "'.$_GET['id'].'"';
$sql_result4 = mysqli_query($mysql, $sql_query4);
$sql_row4 = mysqli_fetch_object($sql_result4);
$filename = $sql_row4->Filename;
$Url_string = 'upload/'.$snrid.'/'.$id.'/'.$filename.'';
if($id != ''){
if (!file_exists('../upload/'.$snrid.'/'.$id.'/'.$filename)) {
header('Content-Type: application/pdf');
// Es wird downloaded.pdf benannt
header('Content-Disposition: inline; filename='.$filename.'');
// Die originale PDF Datei heißt original.pdf
readfile('../upload/'.$snrid.'/'.$id.'/'.$filename);
}
}else{}
?>