0

我想创建一个下载链接,我的所有文件都是 zip,但我不想让我的用户知道我的下载链接在哪里

所以我想获取 zip 文件的内容并将其与 zip 标头回显给用户可以下载它我该怎么做?

4

2 回答 2

0

您应该使用“download.php?get=”。base64_encode($filename) 当用户点击“下载 zip”时,你用 header("Location: download.php?get=".base64_encode($url) 将他重定向到那个页面。标题,我们开始

$filename = base64_decode($_GET[get]);
$filepath = "/var/www/domain/httpdocs/download/path/";

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$filename."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filepath.$filename));
ob_end_flush();
@readfile($filepath.$filename);
于 2012-12-29T11:06:17.800 回答
0

您可以尝试下载一些“准备使用”的php 类,而不是尝试使用标头。然后你可以做类似的事情:

$fileDown = new PHPFileDownload(null, null, 'myFileName', null, 'mypath/myfile.txt');
$fileDown->exportData();
于 2012-12-29T12:04:05.077 回答