파일 업로드 클래스 > 자유게시판

자유게시판

파일 업로드 클래스 정보

파일 업로드 클래스

본문

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;

        }

    }

추천
0
  • 복사

댓글 1개

© SIRSOFT
현재 페이지 제일 처음으로