게시판 첨부 다운로드 할때 파일소스가 그냥 보여지네요
본문
안녕하세요.
잘운영하던 자료 게시판이 갑자기 첨부 다운 클릭 하면 바로 보여져 버리는 상황이
발생 되어 자문을 좀 구해 봅니다.
동일 서버에 다른 사이트는 정상 작동하는데 요사이트만 이러네요 ㅎ..
혹시 비슷한 경험 있으시면 자문 부탁드려요.
감사합니다.
http://intra.cctv119.com/bbs/board.php?bo_table=testt&wr_id=1
답변 1
아래와 같이 해주세요.
<?
include_once('./_common.php');
$code = "$g5[path]/download"; //자신의 경로에 맞게 수정(download의 위치가 다운로드할 파일이있는 위치입니다.)
$file="$code/$filename";
$file_size=filesize($file);
// 브라우저 골라서 헤더를 따로 따로 전송 해 준다.(5.5 일때는 다르게 해줘야 함)
if( strstr($HTTP_USER_AGENT,"MSIE 5.5")){
header("Content-Type: doesn/matter ");
header("Content-Disposition: filename=$filename ");
header("Content-Transfer-Encoding: binary ");
header("Pragma: no-cache");
header("Expires: 0");
}else{
Header("Content-type: file/unknown");
Header("Content-Disposition: attachment; filename=$filename");
Header("Content-Description: PHP3 Generated Data");
header("Pragma: no-cache");
header("Expires: 0");
}
if(is_file("$file")){
$fp = fopen("$file","r");
if (!fpassthru($fp))
fclose($fp);
}
?>
위와 같이 filedown.php로 만들어서 아래의 형태로 사용하세요.
<a href="<?=$g5[path];?>/filedown.php?filename=파일명.확장자명"/>
답변을 작성하시기 전에 로그인 해주세요.