| PHP로 조그만 파일방 만들기 |
Technology 10/08/15 19:48 ( Translate this page  )
글 주소 : http://ohyung.net/623
자세한 내용은 생략..
php 코드로 작게 파일방 운영하려고 코딩

초기에 로그인 -> 자료실 이용 -> 업로드 가능...


폴더에서 파일 리스트 얻어오는법.
소스 코드 타입 : PHP
        if($_GET[folder] != "")
        {
            $folder_current = $VOLUME.$_GET[folder];
            if(!is_dir($folder_current))
            {
                $folder_current = $VOLUME;
            }

            chdir($folder_current);

            $folder_current = getcwd();
            if (substr($folder_current, 0, strlen($VOLUME)) != $VOLUME)
            {
                chdir($VOLUME);
            }
        }
        else
        {
            $folder_current = getcwd();
        }

        $folder_handle = opendir($folder_current);

        $file_array = array();
        $folder_array = array();

        if ($folder_handle) 
        {
            while ($file = readdir($folder_handle)) 
            {
                // 디렉토리 건들고 top으로 넣고
                if($file == "." || $file == "..")
                {
                    if ($VOLUME != $folder_current."/")
                    {
                        $file_folder = substr($folder_current, strlen($VOLUME), strlen($folder_current));
                        array_push($folder_array, array($file_folder."/".$file, $file));
                    }
                }
                // 일반 폴더
                else if(is_dir($file)&& $file != "temp")
                {
                    $file_folder = substr($folder_current, strlen($VOLUME), strlen($folder_current));
                    if($file_folder)
                    {
                        array_push($folder_array, array($file_folder."/".$file, $file));
                    }
                    else
                    {
                        array_push($folder_array, array($file, $file));
                    }
                }
                // 파일들
                else if(is_file($file) && $file != "index.php" && $file != "index.php.bak")  //파일 이면
                {
                    $file_size=(int)(filesize($folder_current."/".$file) / 1024);
                    $file_time = date ("y-m-d H:i", filemtime($folder_current."/".$file));

                    $file_sum += $file_size;
                    $file_folder = substr($folder_current, strlen($VOLUME), strlen($folder_current));
                    if($file_folder)
                    {
                        array_push($file_array, array($file_folder."/".$file, $file, $file_size, $file_time));
                    }
                    else
                    {
                        array_push($file_array, array($file, $file, $file_size, $file_time));
                    }
                }                
            }// while ($file = readdir($folder_handle)) 
            closedir($folder_handle);

            // 소트 대소문구분없이
            usort($folder_array, 'mycmp');
            usort($file_array, 'mycmp');
        }
태그 : (올블로그 tag 검색이올린 tag 검색Technorati tag검색) , (올블로그 tag 검색이올린 tag 검색Technorati tag검색) , (올블로그 tag 검색이올린 tag 검색Technorati tag검색) , (올블로그 tag 검색이올린 tag 검색Technorati tag검색)
| 이 포스트에 대한 이용규약 |
Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시 2.0 라이센스 에 따라 이용하실 수 있습니다.
This work is licensed under a Creative Commons Attribution 2.0 Korea LicenseLink in a new window.

| 트랙백 & 댓글|
트랙백 주소 :: http://ohyung.net/rserver.php?mode=tb&sl=623
댓글을 씁니다. ( Write a comment )