나는 다음과 같은 PHP 코드가 있습니다콘텐츠 유형 헤더를 설정하기 전에 PHP가 에코됩니까?
function download_file($file, $description=null, $filename=false){
$filename = $filename || basename($file);
ob_start();
if(is_string($description)){
$description = preg_replace("/\$1/", $filename, $description);
echo $description;
}
sleep(2);
header('Content-Type: '.$this->file_mimetype($file));
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"" . basename($file) . "\"");
readfile($file);
header("Content-Type: text/html");
ob_end_flush();
}
download_file("https://raw.githubusercontent.com/Gethis/ED/master/easydevop.class.php", "Downloading easydevop.class.php");
문제는 그것을 다운로드하기 전에 "easydevop.class.php 다운로드"반향되지 않도록이다. 나는 또한 모든 머리글 뒤에 그것을 울리는 시도했지만, 그 중 하나를 작동하지 않았다. 제발, 도와주세요. 당신이 볼 수 있듯이
는나는 당신이 "에코"(보여주는 HTML 컨텐츠)를 사용하고 동시에 사용자에게 파일을 보낼 수 없습니다 ob_start()
및 ob_end_flush()
또는 헤더 리디렉션 :'헤더 다음은 테스트 스크립트 ('새로 고침 : HTTP는 : // ...');' – Marek
또는 위치 : 헤더 – Farkie