4G 이상 대용량화일 첨부 및 표시 > 그누보드5 팁자료실

그누보드5 팁자료실

4G 이상 대용량화일 첨부 및 표시 정보

4G 이상 대용량화일 첨부 및 표시

본문

> // does not work with files greater than 4GB 
> // 
> // specifically for 32 bit systems. limit conversions filsize is 4GB or 
> // 4294967296. why we get negative numbers? by what the file 
> // pointer of the meter must work with the PHP MAX value is 2147483647. 
> // Offset file : 0 , 1 , 2 , 3 , ... 2147483647 = 2GB 
> // to go higher up the 4GB negative numbers are used 
> // and therefore after 2147483647, we will -2147483647 
> // -2147483647,  -2147483646, -2147483645, -2147483644 ... 0 = 4GB 
> // therefore 0, 2147483647 and -2147483647 to 0. all done 4GB = 4294967296 
> // the first offset to 0 and the last offset to 0 of 4GB should be added in 
> // your compute, so "+ 2" for the number of bytes exate . 

 

 

 

1. 먼저 php bit 확인

웹루트에 아래화일 생성
aa.php

<?php
echo PHP_INT_MAX;
?>
브라우저에서 확인.

수치가 9223372036854775807  로 나오면 64bit 
만일 수치가 2147483647 이면 32bit 


2. mysql 구조변경

## 테이블: g5_board 

bo_upload_size 컬럼이 int 

그래서 2147483647 까지만 입력되는현상~

bigint 로 변경

## 테이블: g5_board_file

bf_filesize 컬럼이 int 

bigint 로 변경


3. /lib/common.lib.php

## 32bit 라면.

// 파일의 용량을 구한다.
//function get_filesize($file)
function get_filesize($size)
{
    $sizeb = "$size";
    if ($sizeb < 0) {
    return (($sizeb + PHP_INT_MAX) + PHP_INT_MAX + 2);
    }

    if ($sizeb >= 1073741824 ) {
        $size = number_format($sizeb/1073741824, 2) . "G";
    } else if ($sizeb >= 1048576) {
        $size = number_format($sizeb/1048576, 1) . "M";
    } else if ($sizeb >= 1024) {
        $size = number_format($sizeb/1024, 1) . "K";
    } else {
        $size = number_format($sizeb, 0) . "byte";
    }

    return $size;
}


## 64bit 라면

// 파일의 용량을 구한다.
//function get_filesize($file)
function get_filesize($size)
{
    //$size = @filesize(addslashes($file));
    if ($size >= 1073741824 ) {
        $size = number_format($size/1073741824, 2) . "G";
    } else if ($size >= 1048576) {
        $size = number_format($size/1048576, 1) . "M";
    } else if ($size >= 1024) {
        $size = number_format($size/1024, 1) . "K";
    } else {
        $size = number_format($size, 0) . "byte";
    }
    return $size;
}

 

 

## 32bit php 는 예전 서버를 다 없애버려서 확인을 못하네요

문의하신분이 있으셔서 답변을 드렸는데

이게 맞는방식인지 애매한지라 써봅니다..  잘못된부분이 있으면 언능 수정해야겠지요..

추천
4

댓글 9개

일반호스팅처럼 서버에서 업로드 용량 20mb로 제한한 경우도 해당 소스면 변경하면 대용량 업로드가 가능한건가요? 아니면 서버 설정이 되어있는 경우에 소스변경해야할 부분인건가요?
업로드용량 설정은  서버단에서( php.ini )  해야하는것이구요..  대용량화일 첨부시 표시되는 부분에 해당되는것 이예요..
전체 2,411 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

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