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

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

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

번호 제목 글쓴이 날짜 조회
21 1111 가로수 2021.09.23 3513
20 qqqq 가로수 2021.09.23 3452
19 광케이블 접속 손실 기준 가로수 2021.09.04 3290
18 비정품 가로수 2020.12.23 3251
17 메뉴 권한 설정 회원 레벨별로 다르게 출력하기 댓글+1 가로수 2021.01.15 3206
16 초점 시프트 촬영 후 합성(이미지 스택)하는 방법 가로수 2021.07.11 3105
15 기타를 조율하는 가로수 2021.03.19 3045
14 초점 시프트 촬영 후 합성(이미지 스택)하는 방법 가로수 2021.07.12 2950
13 초점 시프트 촬영 후 합성(이미지 스택)하는 방법 가로수 2021.07.12 2840
12 1206IPF-P 기능 가로수 2021.07.04 2821
11 OTDR 측정시 손실 추정값 댓글+1 가로수 2021.10.02 2429
10 광 케이블은 종류에 따라 수명이 달라지나요? 가로수 2021.09.16 2326
9 ssss 가로수 2021.09.23 2073
8 케이블의 국제 표준 및 국가 표준 가로수 2021.09.04 2016
7 php에서 exif소스이용하기 가로수 2022.07.05 1600
6 전선 종류 가로수 2019.08.01 9
5 자동 가상 컴퓨터 정품 인증-Windows Server 2012 R2 가로수 2019.05.14 6
4 PA 의 의미 가로수 2019.06.03 4
3 KMS 클라이언트 설정 키(KMS Client Setup Keys) 및 정품 인증 방법 가로수 2019.05.14 4
2 php 에러 출력하기 가로수 2019.09.20 3
Category
글이 없습니다.
글이 없습니다.
반응형 구글광고 등
State
  • 현재 접속자 22 명
  • 오늘 방문자 243 명
  • 어제 방문자 296 명
  • 최대 방문자 1,053 명
  • 전체 방문자 288,241 명
  • 전체 게시물 50 개
  • 전체 댓글수 5 개
  • 전체 회원수 34 명
Facebook Twitter GooglePlus KakaoStory NaverBand