첨부파일 확장자 출력하기
본문
첨부파일에 확장자를 확인하여 출력하려면 어떻게 해야 하나요?
첨부파일을 넣고 글쓰기를 완료하면
list.skin.php 에서서 첨부파일을 확인하여 hwp 면 hwp아이콘 출력
psd 면 psd 아이콘 출력
mp3 면 mp3 아이콘 출력
이런 부류입니다.
그누4에서 본것 같은데 그누5용은 안 보이네요.
혹시 알려주실분
답변 4
$sql = " select *, substring_index(bf_source, '.', -1) ext from $g5[board_file_table] where bo_table = '". $bo_table. "' and wr_id = '". $list[$i][wr_id] ."' order by bf_no ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result)) echo '<img src="'. $board_skin_url .'/filetype/'. $row['ext'].'.gif" />';
제목 뒤에 아래 소스를 넣어주시고 스킨 폴더에 filetype폴더 만들고 거기에 확장자.gif 이미지 넣으면 되요
$sql = " select * from $g5[board_file_table] where bo_table = '". $bo_table. "' and wr_id = '". $list[$i][wr_id] ."' order by bf_no ";
while ($row = sql_fetch_array($result))
{
$file_source = addslashes($row[bf_source]);
$file_type = $$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $file_source);
echo "<img src='". $board_skin_url ."/filetype/". $file_type .".gif' border=0 align='absmiddle' />";
}
<!-- 제목,내용 출력 -->
<li class="gall_text_href">
<?php if ($is_checkbox) { ?>
<label for="chk_wr_id_<?php echo $i ?>" class="sound_only"><?php echo $list[$i]['subject'] ?></label>
<input type="checkbox" name="chk_wr_id[]" value="<?php echo $list[$i]['wr_id'] ?>" id="chk_wr_id_<?php echo $i ?>">
<?php } ?>
<a href="<?php echo $list[$i]['href'] ?>">
<?php echo $list[$i]['subject'] ?>
<!-- 소스추가부분 -->
<?php
$sql = " select * from $g5[board_file_table] where bo_table = '". $bo_table. "' and wr_id = '". $list[$i][wr_id] ."' order by bf_no ";
while ($row = sql_fetch_array($result))
{
$file_source = addslashes($row[bf_source]);
$file_type = $$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $file_source);
echo "<img src='". $board_skin_url ."/filetype/". $file_type .".gif' border=0 align='absmiddle' />";
}
?>
<!-- 소스추가부분 끝 -->
<?php if ($list[$i]['comment_cnt']) { ?><span class="sound_only">댓글</span><?php echo $list[$i]['comment_cnt']; ?><span class="sound_only">개</span><?php } ?></a>
<?php
// if ($list[$i]['link']['count']) { echo '['.$list[$i]['link']['count']}.']'; }
// if ($list[$i]['file']['count']) { echo '<'.$list[$i]['file']['count'].'>'; }
if (isset($list[$i]['icon_new'])) echo $list[$i]['icon_new'];
if (isset($list[$i]['icon_hot'])) echo $list[$i]['icon_hot'];
//if (isset($list[$i]['icon_file'])) echo $list[$i]['icon_file'];
//if (isset($list[$i]['icon_link'])) echo $list[$i]['icon_link'];
//if (isset($list[$i]['icon_secret'])) echo $list[$i]['icon_secret'];
?>
</li>
<li>
이렇게 추가했는데 반응이 없네요.
소스를 잘못 넣은 걸까요?
슈와이님 소스대로 하니 출력이 되네요.
감사합니다.