게시판 글 엑셀다운 첨부파일 경로 URL
본문
아래 게시판 글 엑셀파일 다운 소스입니다.
여기에서 게시글에 등록된 첨부파일 경로(url)도 추가하고 싶은데
방법을 알고 계신분은 답변 부탁드립니다.
해당 url 클릭하면 다운 받을 수 있게 하고자 합니다.
ex) 다운받은 엑셀에서 pdf 파일경로 또는 zip 파일경로 클릭시 "다운로드 되기"
알기쉽게 코드예제 부탁드립니다.
고수님들 답변 꼭 부탁드립니다. ㅜㅜ
감사합니다.
-------------------------------------------------------
<?php
include_once('_common.php');
echo '<meta charset="utf-8">';
$sql = " select
bo_subject
from g5_board A
where 1 = 1
and bo_table = '{$bo_table}'
";
$title = sql_fetch($sql);
$sql = " select
A.*
from g5_write_{$bo_table} A
where 1 = 1
order by wr_datetime desc
";
$result = sql_query($sql);
header("Content-Type: application/vnd.ms-excel");
header("Content-Type: application/x-msexcel");
header("Content-Disposition: attachment; filename={$bo_table}.xls");
header("Content-Description: PHP4 Generated Data" );
header("Content-charset=utf-8");
?>
<html>
<head>
<style>
.sty { font-family:굴림; font-size:12px;}
.sty0 { font-family:굴림; font-size:12px; text-align:center;}
.sty1 {mso-number-format:"\@";font-family:굴림; font-size:12px}
.sty2 {font-family:굴림; font-size:12px}
.sty3 {font-family:굴림; font-size:12px; color: #ff0000}
.title {font-family:굴림; font-size:12px; font-weight:600}
.title_s {font-family:굴림; font-size:16px}
</style>
</head>
<body bgcolor="#FFFFFF">
<table border="1" style="table-layout:fixed">
<tr>
<td colspan="17" class="title"><?php echo $title['bo_subject'];?></td>
</tr>
<tr align="center">
<td bgcolor="#CCFFCC">순번</td>
<td bgcolor="#CCFFCC">등록일자</td>
<td bgcolor="#CCFFCC">등록자</td>
<td bgcolor="#CCFFCC">제목</td>
<td bgcolor="#CCFFCC">내용</td>
<td bgcolor="#CCFFCC">이메일</td>
<td bgcolor="#CCFFCC">등록아이피</td>
<td bgcolor="#CCFFCC">추가필드1</td>
<td bgcolor="#CCFFCC">추가필드2</td>
<td bgcolor="#CCFFCC">추가필드3</td>
<td bgcolor="#CCFFCC">추가필드4</td>
<td bgcolor="#CCFFCC">추가필드5</td>
<td bgcolor="#CCFFCC">추가필드6</td>
<td bgcolor="#CCFFCC">추가필드7</td>
<td bgcolor="#CCFFCC">추가필드8</td>
<td bgcolor="#CCFFCC">추가필드9</td>
<td bgcolor="#CCFFCC">추가필드10</td>
</tr>
<?php
for ($i=0; $row=sql_fetch_array($result); $i++) {
?>
<tr>
<td class="sty1"><?php echo ($i + 1);?></td>
<td class="sty1"><?php echo substr($row['wr_datetime'], 0, 11);?></td>
<td class="sty1"><?php echo $row['wr_name'] . ' (' . $row['mb_id'] . ')' ;?></td>
<td class="sty1"><?php echo $row['wr_subject'];?></td>
<td class="sty1"><?php echo strip_tags($row['wr_content']);?></td>
<td class="sty1"><?php echo $row['wr_email'];?></td>
<td class="sty1"><?php echo $row['wr_ip'];?></td>
<td class="sty1"><?php echo $row['wr_1'];?></td>
<td class="sty1"><?php echo $row['wr_2'];?></td>
<td class="sty1"><?php echo $row['wr_3'];?></td>
<td class="sty1"><?php echo $row['wr_4'];?></td>
<td class="sty1"><?php echo $row['wr_5'];?></td>
<td class="sty1"><?php echo $row['wr_6'];?></td>
<td class="sty1"><?php echo $row['wr_7'];?></td>
<td class="sty1"><?php echo $row['wr_8'];?></td>
<td class="sty1"><?php echo $row['wr_9'];?></td>
<td class="sty1"><?php echo $row['wr_10'];?></td>
</tr>
<?php }
?>
</table>
</body>
</html>
답변 1
for ($i=0; $row=sql_fetch_array($result); $i++) {
밑에
$file = get_file($bo_table, $row['wr_id']);
for($k=0; $k< $file['count']; $k++){
$fileurl = $file[$k]['path']."/".$file[$k]['file'];
echo '<a href="'.$fileurl.'">다운로드</a>';
}
답변을 작성하시기 전에 로그인 해주세요.