header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=\"". $file ."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
file_get_contents($file);
readfile($file);
exit();
내가 뭘 잘못하고 있니? 내 서버의 파일을 사용자의 하드 드라이브로 다운로드하면 안됩니까? 어떻게 든 모든 파일이 손상되었습니다! 또한 어떻게 내가 다운로드 한 파일의 파일명을 바꿀 수 있는지 궁금합니다.php : 강제로 hd로 다운로드 하시겠습니까?
$file
에는 항상 내 파일의 전체 경로가 포함됩니다. 시도하면 header('Location:' . $file);
브라우저가 성공적으로 내 파일을 엽니 다. 그러나 파일이 .jpg 인 경우 브라우저는 다운로드 창을 표시하지 않습니다. 대신 브라우저 창에서 파일을 엽니 다. 모든 파일을 hd로 다운로드하고 싶습니다.
제발 도와주세요. 나는 일주일 넘게이 일을 끝내고 해결책을 찾을 수 없습니까?
존재하는'파일 이름 = \ "". 파일 이름 : "basename ($ file)."\ ";"'무엇이'file_get_contents ($ file);'라인입니까? – VolkerK