ダウンロード用のリンクを作成したいのですが、ファイルはすべてzipですが、ダウンロードリンクがどこにあるかをユーザーに知らせたくありません。
だから私はzipファイルのコンテンツを取得してユーザーにzipヘッダーでエコーしたいのですが、それをダウンロードするにはどうすればよいですか?
ダウンロード用のリンクを作成したいのですが、ファイルはすべてzipですが、ダウンロードリンクがどこにあるかをユーザーに知らせたくありません。
だから私はzipファイルのコンテンツを取得してユーザーにzipヘッダーでエコーしたいのですが、それをダウンロードするにはどうすればよいですか?
「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);
ヘッダーを試す代わりに、「すぐに使える」phpクラスをダウンロードしてみることができます。次に、次のようなことを行うことができます。
$fileDown = new PHPFileDownload(null, null, 'myFileName', null, 'mypath/myfile.txt');
$fileDown->exportData();