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

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

가로수 0 3,718 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 php에서 exif소스이용하기 가로수 2022.07.05 1576
40 OTDR 측정시 손실 추정값 댓글+1 가로수 2021.10.02 2400
39 ssss 가로수 2021.09.23 2048
38 1111 가로수 2021.09.23 3462
37 qqqq 가로수 2021.09.23 3413
36 광 케이블은 종류에 따라 수명이 달라지나요? 가로수 2021.09.16 2299
35 케이블의 국제 표준 및 국가 표준 가로수 2021.09.04 1987
34 광케이블 접속 손실 기준 가로수 2021.09.04 3250
33 초점 시프트 촬영 후 합성(이미지 스택)하는 방법 가로수 2021.07.12 2803
32 초점 시프트 촬영 후 합성(이미지 스택)하는 방법 가로수 2021.07.12 2906
31 초점 시프트 촬영 후 합성(이미지 스택)하는 방법 가로수 2021.07.11 3061
30 1206IPF-P 기능 가로수 2021.07.04 2770
29 Windows 설치된 MySQL 8 드라이브 변경(C에서 D로 변경) 가로수 2021.04.26 3965
28 기타를 조율하는 가로수 2021.03.19 2997
27 메뉴 권한 설정 회원 레벨별로 다르게 출력하기 댓글+1 가로수 2021.01.15 3159
26 비정품 가로수 2020.12.23 3205
25 재해예방기술지도 계약서 작성대상공사,지도기준,비용 견적(2020.1.1부터) 가로수 2020.06.24 7350
24 게시판 본문 내용 글자 수 제한 해제하기 - 글 내용이 잘리는 문제 해결 방법 가로수 2020.04.12 3670
23 Windows Server 2012 Standard 설치기.... 가로수 2020.01.30 3793
22 나만의 커스텀 윈도우10 만들기 가로수 2020.01.05 4332
Category
글이 없습니다.
글이 없습니다.
반응형 구글광고 등
State
  • 현재 접속자 7 명
  • 오늘 방문자 155 명
  • 어제 방문자 179 명
  • 최대 방문자 1,053 명
  • 전체 방문자 285,723 명
  • 전체 게시물 50 개
  • 전체 댓글수 5 개
  • 전체 회원수 33 명
Facebook Twitter GooglePlus KakaoStory NaverBand