파일 업로드 클래스

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;

        }

    }

|

댓글 1개

class UploadFiles

업로드파일 클래스 정의
댓글을 작성하시려면 로그인이 필요합니다.

자유게시판

+
제목 글쓴이 날짜 조회
18년 전 조회 2,041
18년 전 조회 1,925
18년 전 조회 1,970
18년 전 조회 2,876
18년 전 조회 1,826
18년 전 조회 1,978
18년 전 조회 1,825
18년 전 조회 1,718
18년 전 조회 1,807
18년 전 조회 1,992
18년 전 조회 2,018
18년 전 조회 2,001
18년 전 조회 2,439
18년 전 조회 2,279
18년 전 조회 1,949
18년 전 조회 2,450
18년 전 조회 2,133
18년 전 조회 2,655
18년 전 조회 2,121
18년 전 조회 2,041
18년 전 조회 2,730
18년 전 조회 7,257
18년 전 조회 2,317
18년 전 조회 2,027
18년 전 조회 2,043
18년 전 조회 2,683
18년 전 조회 2,366
18년 전 조회 2,085
18년 전 조회 2,091
18년 전 조회 2,123