최근게시물 목록에서 첨부파일 다운로드가 되지 않아서 문의 드립니다.

최근게시물 목록에서 첨부파일 다운로드가 되지 않아서 문의 드립니다.

QA

최근게시물 목록에서 첨부파일 다운로드가 되지 않아서 문의 드립니다.

본문

3067840266_1758950303.6229.png

저는 최근 게시물 목록에서 바로 첨부된 파일 다운로드를 받고 싶은데 다운 되지 않아요. ㅠㅠ 

별짓을 다 해봤지만, 되지 않아서 고수님들게 문의를 드립니다.

<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

?>
<style>
.latest_dataroom { 
    margin-bottom: 20px; 
    padding: 0;
    border-radius: 8px;
}

.latest_dataroom .dataroom_title { 
    font-size: 1.2em; 
    font-weight: bold; 
    padding: 15px 20px; 
    margin: 0; 
    color: #007bff; 
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px 8px 0 0;
}

.latest_dataroom .lt_ul { list-style: none; margin: 0; padding: 0; }
.latest_dataroom .lt_li { 
    display: flex; 
    align-items: center; 
    padding: 12px 20px; 
    border-bottom: 1px solid #e9ecef; 
    font-size: 0.95em;
    transition: background-color 0.2s;
}
.latest_dataroom .lt_li:last-child { border-bottom: none; }
.latest_dataroom .lt_li:hover { background-color: #f8f9fa; }
.latest_dataroom .empty_li { text-align: center; color: #6c757d; padding: 40px 20px; }

.latest_dataroom .lt_link { 
    flex-grow: 1; 
    overflow: hidden; 
    white-space: nowrap; 
    text-overflow: ellipsis; 
    display: block; 
    padding-right: 15px; 
    text-decoration: none;
    color: #333;
    font-weight: 500;
}
.latest_dataroom .lt_link:hover { text-decoration: none; color: #007bff; }
.latest_dataroom .lt_subject { margin-left: 5px; }

.latest_dataroom .lt_new { 
    background: linear-gradient(45deg, #28a745, #20c997); 
    color: #fff; 
    font-size: 0.7em; 
    padding: 2px 6px; 
    border-radius: 10px; 
    margin-right: 8px; 
    font-weight: bold;
    text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.latest_dataroom .lt_date { 
    width: 90px; 
    font-size: 0.85em; 
    color: #6c757d; 
    flex-shrink: 0; 
    text-align: right;
    font-weight: 500;
}

.latest_dataroom .lt_file_status {
    width: 70px; 
    text-align: center;
    flex-shrink: 0;
}

.latest_dataroom .file_download_area {
    position: relative;
    display: inline-block;
}

.latest_dataroom .file_download_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border-radius: 50%;
    text-decoration: none;
    font-size: 1em;
    position: relative;
    box-shadow: 0 3px 6px rgba(0,123,255,0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.latest_dataroom .file_download_btn:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,123,255,0.4);
    color: white;
    text-decoration: none;
}

.latest_dataroom .file_count_badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(45deg, #dc3545, #c82333);
    color: white;
    font-size: 0.65em;
    padding: 3px 6px;
    border-radius: 12px;
    line-height: 1;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.latest_dataroom .file_dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 280px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 5px;
}

.latest_dataroom .file_item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #f8f9fa;
    font-size: 0.9em;
    transition: all 0.2s;
}

.latest_dataroom .file_item:hover {
    background: #f8f9fa;
    color: #007bff;
    text-decoration: none;
}

.latest_dataroom .file_item:last-child {
    border-bottom: none;
}

.latest_dataroom .file_item .file_icon {
    margin-right: 10px;
    color: #6c757d;
    font-size: 1.1em;
}

.latest_dataroom .file_item .file_name {
    flex-grow: 1;
    font-weight: 500;
}

.latest_dataroom .file_item .file_size {
    color: #6c757d;
    font-size: 0.8em;
    margin-left: 10px;
}

.latest_dataroom .no_file {
    color: #dee2e6;
    font-size: 1.3em;
}

.latest_dataroom .lt_more { 
    text-align: center; 
    padding: 15px 20px; 
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.latest_dataroom .btn_more_link { 
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 20px; 
    border: 2px solid #007bff; 
    color: #007bff; 
    text-decoration: none; 
    font-size: 0.9em; 
    border-radius: 25px; 
    background-color: #fff;
    transition: all 0.3s ease;
    font-weight: 500;
}

.latest_dataroom .btn_more_link:hover { 
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,123,255,0.3);
}
</style>

<script>
// 파일 다운로드 (커스텀 다운로드 파일 사용)
function downloadFile(bo_table, wr_id, file_no, filename) {
    // file_download.php를 사용한 다운로드
    var url = '<?php echo G5_URL; ?>/file_download.php?bo_table=' + bo_table + 
              '&wr_id=' + wr_id + '&no=' + file_no;
    
    // iframe을 통한 다운로드
    var iframe = document.createElement('iframe');
    iframe.style.display = 'none';
    iframe.src = url;
    document.body.appendChild(iframe);
    
    setTimeout(function() {
        if (iframe.parentNode) {
            document.body.removeChild(iframe);
        }
    }, 5000);
}

// 파일 목록 토글
function toggleFileList(event, element) {
    event.preventDefault();
    event.stopPropagation();
    
    // 다른 드롭다운 닫기
    document.querySelectorAll('.file_dropdown').forEach(function(dropdown) {
        if (dropdown !== element.nextElementSibling) {
            dropdown.style.display = 'none';
        }
    });
    
    var dropdown = element.nextElementSibling;
    if (dropdown) {
        dropdown.style.display = dropdown.style.display === 'block' ? 'none' : 'block';
    }
}

// 외부 클릭 시 드롭다운 닫기
document.addEventListener('click', function(event) {
    if (!event.target.closest('.file_download_area')) {
        document.querySelectorAll('.file_dropdown').forEach(function(dropdown) {
            dropdown.style.display = 'none';
        });
    }
});

// 단일 파일 다운로드
function downloadSingleFile(bo_table, wr_id, file_no, filename) {
    downloadFile(bo_table, wr_id, file_no, filename);
}
</script>

<div class="latest_dataroom">
    <?php if ($subject) { ?>
    <h3 class="dataroom_title">
        <i class="fa fa-folder-open" aria-hidden="true"></i> <?php echo $subject ?>
    </h3>
    <?php } ?>
    
    <ul class="lt_ul">
    <?php for ($i=0; $i<count($list); $i++) { 
        // 파일 정보 가져오기
        $files = array();
        
        // DB에서 직접 파일 정보 조회
        $file_sql = "SELECT bf_no, bf_source, bf_file, bf_filesize, bf_download 
                     FROM {$g5['board_file_table']} 
                     WHERE bo_table = '{$bo_table}' AND wr_id = '{$list[$i]['wr_id']}' 
                     AND bf_source != '' 
                     ORDER BY bf_no";
        $file_result = sql_query($file_sql);
        while ($file_row = sql_fetch_array($file_result)) {
            $files[] = $file_row;
        }
        $file_count = count($files);
    ?>
        <li class="lt_li">
            <a href="<?php echo $list[$i]['href'] ?>" class="lt_link" title="<?php echo $list[$i]['subject'] ?>">
                <?php 
                if ($list[$i]['icon_new']) {
                    echo '<span class="lt_new">NEW</span>';
                }
                ?>
                <span class="lt_subject"><?php echo $list[$i]['subject'] ?></span>
            </a>
            
            <span class="lt_date"><?php echo $list[$i]['datetime2'] ?></span>

            <span class="lt_file_status">
                <?php if ($file_count > 0) { ?>
                    <div class="file_download_area">
                        <?php if ($file_count == 1) { 
                            $file = $files[0];
                        ?>
                            <button type="button" 
                                    onclick="downloadSingleFile('<?php echo $bo_table; ?>', '<?php echo $list[$i]['wr_id']; ?>', '<?php echo $file['bf_no']; ?>', '<?php echo addslashes($file['bf_source']); ?>')" 
                                    class="file_download_btn"
                                    title="<?php echo htmlspecialchars($file['bf_source']); ?> 다운로드">
                                <i class="fa fa-download" aria-hidden="true"></i>
                                <span class="file_count_badge">1</span>
                            </button>
                        <?php } else { ?>
                            <button type="button" 
                                    onclick="toggleFileList(event, this)" 
                                    class="file_download_btn"
                                    title="파일 <?php echo $file_count; ?>개 선택">
                                <i class="fa fa-download" aria-hidden="true"></i>
                                <span class="file_count_badge"><?php echo $file_count; ?></span>
                            </button>
                            <div class="file_dropdown">
                                <?php foreach ($files as $file) { ?>
                                    <a href="javascript:void(0)" 
                                       onclick="downloadFile('<?php echo $bo_table; ?>', '<?php echo $list[$i]['wr_id']; ?>', '<?php echo $file['bf_no']; ?>', '<?php echo addslashes($file['bf_source']); ?>')"
                                       class="file_item"
                                       title="<?php echo htmlspecialchars($file['bf_source']); ?>">
                                        <span class="file_icon">
                                            <i class="fa fa-file-o" aria-hidden="true"></i>
                                        </span>
                                        <span class="file_name">
                                            <?php 
                                            $filename = $file['bf_source'];
                                            echo mb_strlen($filename, 'UTF-8') > 30 ? mb_substr($filename, 0, 27, 'UTF-8').'...' : $filename;
                                            ?>
                                        </span>
                                        <?php if ($file['bf_filesize']) { ?>
                                            <span class="file_size"><?php echo get_filesize($file['bf_filesize']); ?></span>
                                        <?php } ?>
                                    </a>
                                <?php } ?>
                            </div>
                        <?php } ?>
                    </div>
                <?php } else { ?>
                    <i class="fa fa-ban no_file" aria-hidden="true" title="첨부파일 없음"></i>
                <?php } ?>
            </span>
        </li>
    <?php } ?>
    <?php if (count($list) == 0) { ?>
    <li class="empty_li">
        <i class="fa fa-folder-open-o" style="font-size: 2em; color: #dee2e6; margin-bottom: 10px;"></i><br>
        게시물이 없습니다.
    </li>
    <?php } ?>
    </ul>
    
    <div class="lt_more">
        <a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $bo_table ?>" class="btn_more_link">
            <i class="fa fa-list"></i>
            전체 자료실 바로가기
        </a>
    </div>
</div>

이 질문에 댓글 쓰기 :

답변 2

다운받기 눌렀을때 페이지 이동은되는건가요?

미동도 없습니다. 첨부 클릭했을 때
콘솔 보니 One or more documents in this page is in Quirks Mode, which will render the affected document(s) with quirks incompatible with the current HTML and CSS specifications.

Quirks Mode exists mostly due to historical reasons. If this is not intentional, you can add or modify the DOCTYPE to be `<!DOCTYPE html>` to render the page in No Quirks Mode.

8 elements
Document in the DOM tree Mode URL
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0
document Quirks Mode https://ksk507.synology.me/ksk507/file_download.php?bo_table=dddf&wr_id=1&no=0

님 말씀처럼 
file_download.php 이걸 코드를 찾아서 붙여넣으니 해결이 되네요 감사합니다 ㅎㅎ

답변을 작성하시기 전에 로그인 해주세요.
전체 101,793 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT