브라우저에서 다운로드해야하는 파일을 열지 않도록 강제 다운로드 페이지를 만들려고합니다. 문제는 다운로드 한 파일이 0 바이트이므로 사용할 수 없다는 것입니다. 내 코드에 어떤 문제가 있습니까?강제로 PHP에서 다운로드
$file = "http://gh0stsec.zxq.net/background1.jpg";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filename));
header("Content-Description: File Transfer");
@readfile($file);
exit();
'application/force-download'는 실제 MIME 형식이 아닙니다. 그것은 지체됐다. 그것이 다운로드를 유발하는 것이 아닙니다. 그것은'Content-Dispositon'입니다. 유효하지 않은 MIME 유형을 추가하는 것은 의미가 없습니다. – mario