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

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

가로수 0 3,712 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

번호 제목 글쓴이 날짜 조회
44 그누보드5 게시판 본문 글씨크기 키우기 가로수 2019.04.29 16387
43 재해예방기술지도 계약서 작성대상공사,지도기준,비용 견적(2020.1.1부터) 가로수 2020.06.24 7333
42 스마트폰 사주는 순간 너를 잃을 수 있다는 게 두렵다 댓글+3 가로수 2019.11.16 7160
41 테스트 가로수 2019.04.19 5803
40 편두통 가로수 2019.11.01 5554
39 독버섯 가로수 2019.09.12 5248
38 테스트 가로수 2019.08.13 4642
37 Evil Science Audio 가로수 2019.07.30 4430
36 전날 밤 꾼 꿈으로 내 건강 상태를 확인한다? 가로수 2019.08.25 4352
35 나만의 커스텀 윈도우10 만들기 가로수 2020.01.05 4314
34 Windows MySQL 5.7 datadir 경로 변경 가로수 2019.08.18 4226
33 Mysql 설치하기 (윈도우) 가로수 2019.04.30 4183
32 광케이블에는 가로수 2019.04.19 4159
31 Windows용 MySQL 5.7 C: 드라이브에서 다른 드라이브로 설치 가로수 2019.04.30 4108
30 Windows 설치된 MySQL 8 드라이브 변경(C에서 D로 변경) 가로수 2021.04.26 3952
29 Windows Server 2012 Standard 설치기.... 가로수 2020.01.30 3778
28 머리가 핑그르르, 갑자기 어지러운 이유는? 가로수 2019.08.20 3764
열람중 4G 이상 대용량화일 첨부 및 표시 가로수 2019.04.29 3713
26 게시판 본문 내용 글자 수 제한 해제하기 - 글 내용이 잘리는 문제 해결 방법 가로수 2020.04.12 3664
25 윈도우10 디펜더 끄기 가로수 2019.11.08 3571
Category
반응형 구글광고 등
State
  • 현재 접속자 9 명
  • 오늘 방문자 278 명
  • 어제 방문자 251 명
  • 최대 방문자 1,053 명
  • 전체 방문자 284,364 명
  • 전체 게시물 56 개
  • 전체 댓글수 5 개
  • 전체 회원수 33 명
Facebook Twitter GooglePlus KakaoStory NaverBand