아! 진짜 좀 도와주세요!!!

아! 진짜 좀 도와주세요!!!

QA

아! 진짜 좀 도와주세요!!!

본문

벌써 몇일째 투쟁중입니다. 좀처럼 풀리지가 않습니다.

이래저래 해봐도 안되니 고수님들 좀 도와주세요~~~

 

게시판을 엑셀로 다운로드 하고 있습니다.

자료들은 잘 다운되는데 

첨부파일 이미지가 엑박만 뜨고 나오지가 않습니다.

경로는 맞는것 같은데 첨부파일을 못불러오는것 같은데 어찌해야할지

검색을 하다가 보니 소스가 있어서 적용을 해봤는데요.

========================================================

<?
include_once("./_common.php");

/*======================================================================
 추가 검색 및 체크박스 된것만 다운로드
======================================================================*/
$fr_date = preg_replace('/[^0-9_\-]/', '', $fr_date);
$to_date = preg_replace('/[^0-9_\-]/', '', $to_date);

$csv = 'xls';
// MS엑셀 XLS 데이터로 다운로드 받음
if ($csv == 'xls')
{
if(is_array($_POST['chk_wr_id']) && count($_POST['chk_wr_id'])) {
    // 체크박스로 선택된게 있을 경우 뽑을 것을 직접 지정한 것이라 다른 조건 필요없음.
    $wr_id_list = '';
    $comma = '';
    for ($i=0; $i<count($_POST['chk_wr_id']); $i++) {
        $wr_id_list .= $comma . $_POST['chk_wr_id'][$i];
        $comma = ',';
    }
    $wr_id_list = preg_replace('/[^0-9,]/', '', $wr_id_list);
    $searches = " and wr_id in ({$wr_id_list}) ";
} else if($stx) {
    // 검색어($stx)로 찾는 쿼리문
    $searches = " and (wr_4 = '{$stx}' or as_tag = '{$stx}' or wr_1 = '{$stx}' or wr_2 = '{$stx}' or wr_5 = '{$stx}' or wr_subject = '{$stx}'  or wr_3 = '{$stx}' or wr_11 = '{$stx}') ";
} else {
    // 전체 다 뽑는 쿼리문
    $searches = "";
}
  
    $sql = " SELECT * FROM g5_write_{$bo_table} where wr_is_comment = '0' {$searches} ";
    $result = sql_query($sql);
    $cnt = sql_num_rows($result); 
    if (!$cnt)
        alert("출력할 내역이 없습니다.");


}


/*======================================================================
 기존 테이블로 엑셀다운
======================================================================*/
if ($csv =="xls"){
$g5[title] = "엑셀 문서 다운로드";
  header("Content-Type: application/x-msexcel; name=\"{$bo_table}-".date("yy-m-d", time()).".xls\"");
  header("Content-Disposition: inline; filename=\"{$bo_table}-".date("yy-m-d", time()).".xls\"");
  //header( "Content-Description: PHP4 Generated Data" );
 }
  header( "Content-Description: PHP5 Generated Data" );

  $sql = " SELECT * FROM g5_write_{$bo_table} where wr_is_comment = '0' {$searches} ";
  $result = sql_query($sql);
  $cnt = sql_num_rows($result); 
  if (!$cnt)
     alert("출력할 내역이 없습니다.");

================================================================

// 첨부파일 추출 시작 
$bo_table=$_GET['bo_table'];
$wr_id=(int)$_GET['wr_id'];

include_once(G5_LIB_PATH.'/thumbnail.lib.php'); // 추가해 주어야 함
$imgwidth = "100";
$imgheight = "160";
$filename = $list[$i][file][0][bf_file]; // 0 첫번째 2 세번째
$filepath = '/주소/'.$bo_table;
$tname = thumbnail($filename, $filepath, $imgwidth, $imgheight, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
$src = G5_URL.str_replace($filename, $tname, $ata_path);
$img_content1 = '<img src="'.$tname['src'].'" alt="'.$tname['alt'].'" width="'.$imgwidth.'" height="'.$imgheight.'">';

 

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">

.txt {mso-number-format:'\@'}
</style>
</head>

<body>
        <img src=<?php echo $img_content1;?>>  <- 엑박뜨는 이미지->
<table>

<?
while($data=sql_fetch_array($result)) {    
    
echo "
<tr>
    <td>번호</td>
    <td>제목</td>
    <td>아이디</td>
    <td>이름</td>
    <td>작성일</td>
    <td>이메일아이디</td>
    <td>이메일</td>
    <td>상품권번호</td>
    <td>주소</td>
    <td>핸드폰번호</td>
  </tr>

  <tr>
    <td>$number</td>
    <td>$data[wr_subject]</td>
    <td>$data[mb_id]</td>
    <td>$data[wr_name]</td>
    <td class='txt'>$data[wr_datetime]</td>

 
    <td class='txt'>$data[wr_1]</td>
    <td class='txt'>$data[wr_2]</td>
    <td class='txt'>$data[wr_5]</td>
    <td class='txt'>$data[wr_9]</td>
    <td class='txt'>$data[wr_10]</td>
    <td class='txt'></td>
  </tr>
";

  }
?>
</table>

</body>
</html>

 

=================================================

이렇게 하면 이미지 나올듯 한데 계속 안되네요.

뭐가 빠진걸까요? 고수님들 좀 도와주세요.. 정말 안풀리네요... ㅠㅠ

이 질문에 댓글 쓰기 :

답변 5

소스에서 header 처리 부분을 빼면 일반 html 페이지 형태로 나옵니다.

 

 header("Content-Type: application/x-msexcel; name=\"{$bo_table}-".date("yy-m-d", time()).".xls\"");
  header("Content-Disposition: inline; filename=\"{$bo_table}-".date("yy-m-d", time()).".xls\"");
 
  header( "Content-Description: PHP5 Generated Data" );

 

라인 주석 처리 (or 삭제)

 

 

일반 html 페이지 형태로 먼저 확인해보는 것을 추천드립니다.

 

일반 html 페이지 형태에서 1) 이미지가 제대로 표시되는지, 2) 이미지 표시되는 부분의 src 가 웹url 형태로 나오는지 등을 먼저 확인해 볼 수 있습니다.

 

일반 html 페이지 형태에서도 이미지가 제대로 표시되지 않는다면, img 태그의 src 부분이 어떻게 되어있는지를 확인하여 수정하시거나 별도의 질문글을 올려볼 수 있습니다.

 

그런 후,일반 html 페이지 형태에서는 이미지가 제대로 표시되는데, header 부분 코드를 다시 적용하여 엑셀에서 확인했을 때 이미지가 표시되지 않는다면.. 그 부분을 다시 찾아보거나 새로 질문글을 올려보는 것이 좋을 듯 합니다.

<img src=<?php echo $img_content1;?>>  <- 엑박뜨는 이미지->

 

위 코드를 아래 코드로 수정해서 해보세요.

<?php echo $img_content1;?>

 

 

이미 위 PHP 코드에서 이미지 태그가 붙어 있습니다.

$img_content1 = '<img src="'.$tname['src'].'" alt="'.$tname['alt'].'" width="'.$imgwidth.'" height="'.$imgheight.'">';


$img_content1 = '<img src="'.$tname['src'].'" alt="'.$tname['alt'].'" width="'.$imgwidth.'" height="'.$imgheight.'">';
...
<img src=<?php echo $img_content1;?>>

이렇게 표현되네요? 소스 보기를 하면 어떻게 나오는지 모르지만 


<?php echo $img_content1;?>

이렇게 해야 되는거 아닌가요?

해봤어요. 그런데 이래저래 안되네요. 불러오는거 될것 같은데 왠 안나올까요? 경로가 틀려서 그런가요. 아니면 data/file/$bo_table 안에 파일을 못찾아서 그런가요? 와 진짜 미치것어요...ㅠㅠ

엑셀다운받으면요.. 이미지 이렇게 나오거든요.

엑박으로 되요. 왜 안불러와지는지... 참나..ㅠㅠㅠ

 

thumb-2949447911_1580465752.2821_730x621.gif

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

회원로그인

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