개발! 딱 깔끔하고 센스있게!

파일 php 의 헤더 파일 을 다운로드 할 수 있 습 니 다. 본문

개발 스크랩 메모/PHP

파일 php 의 헤더 파일 을 다운로드 할 수 있 습 니 다.

렉사이 2020. 12. 3. 23:56

웹 루트 에 있 지 않 은 파일 중 일부 가 다운로드 되 어야 합 니 다.

그래서 아래 에 있 는 다운로드 파일 로 요청 하 는 스 크 립 트 가 있 습 니 다.

문 제 는 내 가 다운로드 한 모든 파일 이 손상 되 었 다 는 것 입 니까?이 파일 들 은 내 가 FTP 로 다운로드 하면 열 릴 것 이기 때문에 문제 가 없다.

다음은 메 일 헤더:

header($_SERVER["SERVER_PROTOCOL"] . " 200 OK"); header("Cache-Control: public"); // needed for i.e. header("Content-Type: " . $download[0]['mime']); header("Content-Disposition: attachment; filename=" .$download_file); header("Content-Transfer-Encoding: Binary"); header("Content-Length:".filesize($attachment_location)); readfile($attachment_location); 

대답 하 다.

다음은 이 목적 에 사용 할 제목 예제 입 니 다:http: / ph. net / manual / n / function. readfile. phop

 header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); 
Comments