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 に答える