-
그누보드 다중파일다운로드(압축다운로드)그누보드 스킨 2021. 2. 16. 18:08
//지정한 게시판의 모든게시글의 파일을 압축후 다운로드
사용법
라이브러리 압축 클래스 파일추가
//원하는게시판번호와 분류코드를 입력 분류코드가 없는경우 빈값을 전송
//list.skin.php <?php if ($admin_href) { ?><li><a href="/bbs/zip_download.php?bo_table=<?= $bo_table ?>&sca=<?= $_GET["sca"] ?>" class="btn_design1" target="_blank">파일다운로드(<?= $_GET["sca"] ?>)</a></li><?php } ?> //링크 추가 //분류별 파일을 다운로드 <?php require 'cla_directzip.php'; $zip = new DirectZip(); $zip->open('브라우저로 보낼 압축파일 이름.zip'); $zip->addFile('/tmp/추가할 파일.jpg', '압축파일 내 파일 이름.jpg'); $zip->addEmptyDir('압축파일 내 폴더 이름'); // 안 해도 상관없음. $zip->addFile('/tmp/추가할 파일2.png', '압축파일 내 폴더 이름/압축파일 내 파일 이름.png'); $zip->addFile('/tmp/추가할 파일3.jpg'); // 압축파일에 파일을 '추가할 파일3.jpg'로 추가 $zip->addFromString('바로 글쓰기.txt', '파일 내용'); // 압축파일에 '파일 내용'을 '바로 글쓰기.txt'로 추가 $zip->close(); ?>
소스
<?php include_once('./_common.php'); // clean the output buffer ob_end_clean(); $sca = $_GET["sca"]; if($sca) { $sWhere = " WHERE ca_name = '{$sca}' "; } //게시판글 검색 $boardSql =" SELECT * FROM g5_write_{$bo_table} {$sWhere} ORDER BY wr_id ASC; "; $boardRes = sql_query($boardSql); include_once G5_LIB_PATH.'/cla_directzip.php'; $zip = new DirectZip(); $zip->open($sca.'.zip'); while($res = sql_fetch_array($boardRes)) { $sql = " select bf_source, bf_file from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$res["wr_id"]}' "; $file = sql_fetch($sql); if(!$file['bf_file']) { continue; } $filepath = G5_DATA_PATH.'/file/'.$bo_table.'/'.$file['bf_file']; $filepath = addslashes($filepath); if (!is_file($filepath) || !file_exists($filepath)) { continue; } $original = $file['bf_source']; $zip->addFile($filepath, $res["wr_id"]."-".$original); } $zip->close(); //게시글들의 모든파일을 읽어 압축후 해당파일을 다운로드 ?>
'그누보드 스킨' 카테고리의 다른 글
그누보드 게시판 구글스프레드시트 연동(구글스프레드시트API) (0) 2021.02.17 그누보드 에디터 글 이미지 수정시 기존 이미지파일이 남는것 삭제하는 로직 (1) 2021.02.16 그누보드 댓글 에디터 적용(댓글 수정,삭제,등록일 수정) (0) 2021.02.16 메인 빠른문자보내기 (0) 2021.01.29 제로보드DB 그누보드DB변환 (0) 2021.01.29