답변 2개 / 댓글 6개
채택된 답변
+20 포인트
<a href="download.php?file=./temp/test.hwp">download</a>
download.php
<?php
$filesize = filesize($_GET['file']);
$path_parts = pathinfo($_GET['file']);
$filename = $path_parts['basename'];
$extension = $path_parts['extension'];
header("Pragma: public");
header("Expires: 0");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$filename);
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$filesize);
ob_clean();
flush();
readfile($_GET['file']);
답변에 대한 댓글 5개
답변을 작성하려면 로그인이 필요합니다.

확장자 제한을 추가해야 할 것 같네요