PHP [CI] file 내용 불러오기, 내용 업데이트 하기

2013.09.24 21:49

juro 조회 수:461

public function css_test()
        {
                //파일 생성,읽기 테스트
                $string = read_file('u_css/test.css');
                //$string = read_file('css/screen.css');
                if($string){
                        //echo $string;
                        echo "You have a Css file!<br/>";
                }else{
                        echo 'Can not read this file!<br/>';
                }
                echo '<br/><br/>';
                
                //글 작성 권한 설정
                $data = 'test123';
                if ( ! write_file('u_css/test1.css', $data)){
                         echo 'Unable to write the file';
                }else{
                         echo 'We can write some things on the file!<br/>';
                }
                
                //파일 생성,읽기 테스트
                echo '
                        <form name="css_change" action="/page/update_css" method="post">
                                <textarea name="css_con" style="width:300px; height:200px;">'.$string.'</textarea><br/>
                                <input type="submit" value="submit"/>
                        </form>
                ';
        }
        public function update_css()
        {
                $this->load->helper('file');
                $css_con=$this->input->post('css_con');
                //echo $css_con;

                //글 작성 권한 설정
                //$css_con = 'test123';
                if ( ! write_file('u_css/test1.css', $css_con))
                {
                         echo 'Unable to write the file';
                }
                else
                {
                         echo 'Updated!<br/>';
                }
                
                write_file('u_css/test.css', $css_con,'r+');

                //파일 생성,읽기 테스트
                $string = read_file('u_css/test.css');
                if($string){
                        echo $string;
                }else{
                        echo 'test';
                }
                echo '<br/><a href="/page/css_test" target="_self">돌아가기</a><br/>';
        }

© juroweb 2003-2014. All rights reserved
log in