Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取zip文件的内容并将其回显给用户_Php - Fatal编程技术网

Php 获取zip文件的内容并将其回显给用户

Php 获取zip文件的内容并将其回显给用户,php,Php,我想做一个下载链接,我所有的文件都是zip文件,但我不想让我的用户知道我的下载链接在哪里 所以我想获取zip文件的内容,并使用zip头将其回显给用户,以便用户可以下载它。我如何才能做到这一点?您应该使用“download.php?get=”。base64_编码($filename) 当用户单击“下载zip”时,您用标题(“Location:download.php?get=“.base64_encode($url)”将其重定向到该页面。 标题,我们开始 $filename = base64_de

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

所以我想获取zip文件的内容,并使用zip头将其回显给用户,以便用户可以下载它。我如何才能做到这一点?

您应该使用“download.php?get=”。base64_编码($filename) 当用户单击“下载zip”时,您用标题(“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);

您可以尝试下载一些“ready for use”(准备使用),而不是尝试使用标题。然后您可以执行以下操作:

$fileDown = new PHPFileDownload(null, null, 'myFileName', null, 'mypath/myfile.txt');
$fileDown->exportData();

请检查此问题及其答案!另外,如果要使下载链接唯一,只需添加“&u=base64_encode(time()”,然后解码字符串并将下载可访问性限制为10分钟。my firend我尝试了此操作,但当文件准备下载时,显示0字节,我确定我的目标(文件路径正常)。。。。