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

时间:2012-12-29 10:56:02

标签: php

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

所以我想获得zip文件的内容并用zip标题回复它给用​​户可以下载它我该怎么办?

2 个答案:

答案 0 :(得分:0)

你应该使用“download.php?get =”。 BASE64_ENCODE($文件名) 当用户单击“下载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);

答案 1 :(得分:0)

您可以尝试下载一些可以随时使用的标题,而不是试用标题。 php class。然后你可以做类似的事情:

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