이것은 오랜 구식 질문이며 이런 식으로 일하는 데 문제가 있는지 확실하지 않지만 최근에 문제가 발생하여 해결책으로 사용하는 것으로 끝났습니다.
저장이 음악과 같은 폴더에 PHP 파일 (예 : downloadmusicfile.php)과 같이
<?php
$filename = $_GET['file'];
if (isset($filename))
{
// Prevents access to something that is not in the same directory as this script
if(substr_count($filename,"/") > 0)
{
die('This should not happen.');
};
$len = filesize($filename);
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/force-download');
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$len);
readfile($filename);
}
else
{
die('No file specified.');
};
?>
는 다음과 같이 파일을 사용하고 있습니다 :
<a href="downloadmusicfile.php?file=song.mp3">Link Name</a>
이이 강제 사용자가 한 번/왼쪽으로 다운로드 링크를 클릭하면 "다른 이름으로 저장"상자가 나타납니다.
1을 다운로드 속성을 사용하여. 나는 다운로드를 강제하는 것이 적절한 경우 (예 : 보고서 내보내기) 특정 시나리오가 있다고 덧붙이고 싶지만 여기에서는 적용하지 않는 것으로 인정합니다. – Basic