PHP readfile()

1 개요[ | ]

PHP readfile()
  • 파일을 출력하는 PHP 함수

2 웹 실행예시[ | ]

<?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 실행예시[ | ]

root@zetawiki:~# cat greet.txt
hello
root@zetawiki:~# cat readfile.php 
<?php
readfile('greet.txt');
root@zetawiki:~# php readfile.php 
hello

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}