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

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

가로수 0 3,738 2019.04.29 20:52

본문

> // 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 는 예전 서버를 다 없애버려서 확인을 못하네요

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

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

Comments

번호 제목 글쓴이 날짜 조회
41 테스트 가로수 2019.04.19 5843
40 광케이블에는 가로수 2019.04.19 4190
39 그누보드5 게시판 본문 글씨크기 키우기 가로수 2019.04.29 16420
열람중 4G 이상 대용량화일 첨부 및 표시 가로수 2019.04.29 3739
37 Windows용 MySQL 5.7 C: 드라이브에서 다른 드라이브로 설치 가로수 2019.04.30 4139
36 Mysql 설치하기 (윈도우) 가로수 2019.04.30 4218
35 KMS 클라이언트 설정 키(KMS Client Setup Keys) 및 정품 인증 방법 가로수 2019.05.14 4
34 자동 가상 컴퓨터 정품 인증-Windows Server 2012 R2 가로수 2019.05.14 6
33 게시판 기본 글씨 폰트 크기 및 줄 간격 변경하기 스마트에디터 포함 가로수 2019.05.17 2
32 PA 의 의미 가로수 2019.06.03 4
31 Evil Science Audio 가로수 2019.07.30 4465
30 전선 종류 가로수 2019.08.01 9
29 테스트 가로수 2019.08.13 4686
28 Windows MySQL 5.7 datadir 경로 변경 가로수 2019.08.18 4260
27 머리가 핑그르르, 갑자기 어지러운 이유는? 가로수 2019.08.20 3797
26 전날 밤 꾼 꿈으로 내 건강 상태를 확인한다? 가로수 2019.08.25 4390
25 독버섯 가로수 2019.09.12 5299
24 php 에러 출력하기 가로수 2019.09.20 3
23 편두통 가로수 2019.11.01 5599
22 윈도우10 디펜더 끄기 가로수 2019.11.08 3608
Category
글이 없습니다.
글이 없습니다.
반응형 구글광고 등
State
  • 현재 접속자 7 명
  • 오늘 방문자 174 명
  • 어제 방문자 261 명
  • 최대 방문자 1,053 명
  • 전체 방문자 286,723 명
  • 전체 게시물 50 개
  • 전체 댓글수 5 개
  • 전체 회원수 33 명
Facebook Twitter GooglePlus KakaoStory NaverBand