こんにちは、製品に関連するデモ ファイルのダウンロードを許可しようとしています。私のコードはこのようなものです
if(isset($_POST['submit'])){
$root = $_SERVER['DOCUMENT_ROOT'];
$path = "/download/";
$path = $root.$path;
$filename = $demo;
$file = $path.$filename;
header('Content-Type: application/force-download');
header("Content-Transfer-Encoding: Binary");
header("Content-Disposition: attachment; filename=\"".basename($file)."\";" );
header("Content-Length: ".filesize($file));
readfile($file);
}
製品に関連付けられているファイル名を取得できます
$デモ
ユーザーが自分の情報を送信すると、ダウンロードが自動的に開始されます。現在、これは、存在しないファイルまたは破損したファイルを適切なファイル名でダウンロードしています。助けてください