내 서버에 PDF 파일로 가득 찬 디렉토리가 있습니다. 파일을 열고 PDF 이름을 클릭하고 내용을보고 싶습니다. 이제는 목록에있는 파일의 이름 만 가져올 수 있지만 그게 전부입니다. 이름을 눌러 PDF를여십시오.서버 쪽 디렉토리를 열고 파일을 엽니 다.
<?php
$sub = ($_GET['dir']);
$path = 'pedidos/';
$path = $path . "$sub";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
if (substr($file, -4, -3) =="."){
echo "$i. $file <br />";
}else{
echo "$i. <a href='?dir=$sub/$file'>$file</a><br />";
}
$i++;
} }
closedir($dh); ?>
http://php.net/manual/en/function.file-get-contents.php –