파일 업로드 클래스 > 십년전오늘

십년전오늘

10년전 추억의 책장을 넘기며

파일 업로드 클래스 정보

파일 업로드 클래스

본문

class UploadFiles

    {

        function getFile($files, $n=0)

        {

            global $FILE_UPLOAD_DIR;

    

            return $this->getFileA($files, $FILE_UPLOAD_DIR, $n);

        }

 


        function getFileA($files, $dir, $n=0)

        {

            $arr=array();

 

            $fileName = preg_replace("/.[^.]*$/i", "", $files['name']);

            $fileExt = substr(strrchr($files['name'], "."), 1);

            $filePath = $dir."/".$fileName.".".$fileExt;

 

            $cnt = 0;

            while(file_exists($filePath)){

                $filePath = $fileName."[".(++$cnt)."].".$fileExt;

            }

 

            move_uploaded_file($files['tmp_name'][$n], $filePath);

            chmod($filePath, 0777);

 

            $arr['file_name'] = $files['name'][$n];

            $arr['file_ext'] = $fileExt;

            $arr['file_dir'] = $filePath;

            $arr['file_size'] = $files['size'][$n];

            $arr['file_bigo'] = $files['type'][$n];

 

            return $arr;

        }

 

 

        function getFiles($files)

        {

            global $FILE_UPLOAD_DIR;

 

            return $this->getFilesA($files, $FILE_UPLOAD_DIR);

        }

 

 

        function getFilesA($files, $dir)

        {

            $arr = array();

 

            for($i = 0; $i < count($files); $i++)

            {

                $arr[] = $this->getFileA($files, $dir, $i);

            }

 

            return $arr;

        }

    }

댓글 전체

전체 135,051
십년전오늘 내용 검색

회원로그인

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