1 개요[ | ]
- PHP readfile()
- 파일을 출력하는 PHP 함수
2 웹 실행예시[ | ]
PHP
Copy
<?php
$file = '/usr/share/apache2/icons/ubuntu-logo.png';
if( !file_exists($file) ) {
echo "파일이 없습니다.";
exit;
}
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
3 CLI 실행예시[ | ]
Console
Copy
root@zetawiki:~# cat greet.txt
hello
Console
Copy
root@zetawiki:~# cat readfile.php
<?php
readfile('greet.txt');
Console
Copy
root@zetawiki:~# php readfile.php
hello
4 같이 보기[ | ]
- PHP fpassthru() - 파일포인터에서 남은 데이터 모두 출력
- PHP file_get_contents() - 파일전체내용을 문자열로 읽기
- PHP file() - 파일전체내용을 배열로 읽기
- PHP fopen() - 파일 또는 URL 열기
- PHP include
- PHP require
- PHP virtual() - 아파치 서브-리퀘스트 수행
5 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.