download.php 샘플 > 기술자료 | 해피정닷컴

download.php 샘플 > 기술자료

본문 바로가기

사이트 내 전체검색

download.php 샘플 > 기술자료

PHP download.php 샘플

페이지 정보


본문

[ view.php ]

<a href="download.php?idx="<?=$idx?>" target="bbsHidden">클릭</a>
<iframe name="bbsHidden" src="about:blank" style="display:none"></iframe>


[ download.php ]

<?PHP
include_once "_common.php";
include "../dbconfig.php";
$dbconn = mysql_connect("$mysql_host","$mysql_user","$mysql_password") or die("데이터베이스 연결에 실패하였습니다.");
mysql_select_db($mysql_db,$dbconn);
//@mysql_query("set names utf8");   // 한글문제 생기면 주석 해제

$tableName = "hp_download";
$idx = $_GET[idx];
$gubun = $_GET[gubun];

if ($gubun != "1") {
  if (!$member[mb_id]) {  // 회원이면 다운로드 가능
    echo "<script>";
    echo "alert('회원로그인후 다운로드 가능합니다.');";
    echo "window.parent.location.href='/gnuboard/bbs/login.php?url=/mts/product.php';";
    echo "</script>";
    //echo ("<script>alert('회원로그인후 다운로드 가능합니다.'); history.back();</ script>");
  //if ($member[mb_level] >= 3) {  // 3등급이상일때 다운로드 가능
  //    echo ("<script>alert('관리자에 문의하세요'); history.back();</ script>");
  }
}

$strSQL = "select * from ".$tableName." where idx='".$idx."' ";
$result = mysql_query($strSQL);
$reusltNum = mysql_num_rows($result);
$resultRow = mysql_fetch_array($result);
$filepath = "/home/happyjung/public_html".$resultRow[downFile]; // 파일경로 설정
$downCount = $resultRow[download] +1;
$filename = basename($filepath); // URL 에서 이름만 뽑아낸다

if (file_exists($filepath)) {
    if(preg_match("/msie/i", $_SERVER[HTTP_USER_AGENT]) && preg_match("/5\.5/", $_SERVER[HTTP_USER_AGENT])) {
      header("content-type: doesn/matter");
      header("content-length: ".filesize($filepath));
      header("content-disposition: attachment; filename=\"$filename\"");
      header("content-transfer-encoding: binary");
    } else {
      header("content-type: file/unknown");
      header("content-length: ".filesize($filepath));
      header("content-disposition: attachment; filename=\"$filename\"");
      header("content-description: php generated data");
    }
    header("Pragma: no-cache");
    header("Expires: 0");
    $fp = fopen($filepath,'rb') ;
    if (!fpassthru($fp)) {
        fclose($fp);
    }
    // 다운로드수 증가하기
    $strSQL = "update ".$tableName." SET download='". $downCount ."' where idx='".$idx ."'";
    $result = mysql_query($strSQL);

    
    if ($member[mb_id] == "") $mb_type = "1";
    else $mb_type = "0";
     
    $fileSQL = "insert into hp_download_user (idx, mb_id, date) values ('$idx', '$member[mb_id]', now() )";
    $result = mysql_query($fileSQL);
    //echo $fileSQL;
    
} else {
    // 파일저장 경로에 파일이 존재하는 않는 경우.
    echo ("<script>alert('파일이 존재하지 않습니다.'); history.back();</script>");
}
    
?>

댓글목록

등록된 댓글이 없습니다.


Total 196건 7 페이지
  • RSS
기술자료 목록
76
PHP   16307  2010-08-21 09:37 ~ 2014-10-06 00:00  
75
PHP   22150  2010-07-21 21:47 ~ 2024-03-22 08:47  
74
PHP   22226  2010-07-10 15:48 ~ 2021-01-03 22:59  
73
PHP   27755  2010-04-13 23:06  
72
PHP   26154  2010-03-24 18:51 ~ 2022-09-27 10:16  
71
PHP   19217  2010-03-21 12:30 ~ 2020-11-15 19:34  
70
PHP   19510  2010-03-18 22:00 ~ 2016-03-17 00:00  
69
PHP   20941  2010-03-16 22:11 ~ 2020-02-08 11:51  
68
PHP   26122  2010-03-08 19:42 ~ 2010-03-08 00:00  
67
PHP   38193  2009-10-23 02:37 ~ 2015-05-26 00:00  
66
PHP   23505  2009-10-21 19:46 ~ 2009-10-21 00:00  
65
PHP   15882  2009-10-14 11:12  
64
PHP   17606  2009-10-10 10:00 ~ 2017-05-19 00:00  
63
PHP   23614  2009-09-09 22:42  
62
PHP   15209  2009-08-25 20:51  
61
PHP   15540  2009-08-25 20:50  
열람
PHP   25281  2009-08-25 20:46 ~ 2020-04-08 11:35  
59
PHP   45966  2009-08-21 01:29 ~ 2017-08-03 00:00  
58
PHP   12974  2009-08-06 22:35  
57
PHP   16277  2009-07-22 18:49  

검색

해피정닷컴 정보

회사소개 회사연혁 협력사 오시는길 서비스 이용약관 개인정보 처리방침

회사명: 해피정닷컴   대표: 정창용   전화: 070-7600-3500   팩스: 042-670-8272
주소: (34368) 대전시 대덕구 대화로 160 대전산업용재유통단지 1동 222호
개인정보보호책임자: 정창용   사업자번호: 119-05-36414
통신판매업신고: 제2024-대전대덕-0405호 [사업자등록확인]  
Copyright 2001~2025 해피정닷컴. All Rights Reserved.