baker95935

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
    public function testfile()
    {
        $cfile='F:\phpStudy\WWW\thinkphp5practise\NNWinLoseConfig.ini';
        $cfilehandle=fopen($cfile,"r"); 
        $editfile=fread($cfilehandle,filesize($cfile)); 
        $encoding = mb_detect_encoding($editfile, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII'));
        $editfile = iconv($encoding, 'UTF-8', $editfile);
        fclose($cfilehandle); 
        echo "<form action='/index/index/testfiledo' method=post>"; 
        echo "<textarea cols=60 rows=15 name=copy id=code>"; 
        echo $editfile; 
        echo "</textarea>";  
        echo "<p><input type=submit value='submit' name=edit><input type=reset value='reset'></form>";
    }

    public function testfiledo()
    {
        $cfile='F:\phpStudy\WWW\thinkphp5practise\NNWinLoseConfig.ini';
        $copy=$_POST['copy'];
        $cfilehandle=fopen($cfile,"wb"); 
        flock($cfilehandle, 2);
        fputs($cfilehandle,stripslashes(str_replace("/x0d/x0a", "/x0a", $copy)));
        fclose($cfilehandle); 
        echo "修改成功了!"; 
        echo "<a href='/Admin/Config/changefile'>查看</a>;
    }

 

posted on 2018-01-09 16:23  baker95935  阅读(1706)  评论(0编辑  收藏  举报