欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

thinkphp下kindeditor显示文件列表

程序员文章站 2024-01-28 14:22:52
...

注:一下为个人总结所用.

前段页面:

  KindEditor.ready(function (K) {
                editor = K.create('#content', {
                    allowFileManager: true,
                    uploadJson: '/index.php/Home/IndexPost/uploadImg',
                    fileManagerJson : '/index.php/Home/IndexPost/fileList'
                });
            });

 

后端php代码:

  $filesArray = array();
        $dir_publicupload = I('get.path', '');
        if (empty($dir_publicupload)) {
            $dir_publicupload = './Public/Uploads/';
        }
        $files1 = scandir($dir_publicupload);

        foreach ($files1 as $file) {

            if ($file == '.' || $file == '..') {
                continue;
            }

            $sub_dir = $dir_publicupload . '/' . $file;
            $pathinfo = pathinfo($sub_dir);
            $filesArray[] =
                array(
                    'is_dir' => is_dir($sub_dir),
                    'has_file' => (is_dir($sub_dir)),
                    'filesize' => 0,
                    'dir_path' => $dir_publicupload,
                    'filename' => $pathinfo['basename'],
                    'is_photo' => ($pathinfo['extension'] && in_array($pathinfo['extension'],array('jpg', 'gif', 'png', 'jpeg'))),
                    'filetype' => ($pathinfo['extension'] ? $pathinfo['extension'] : ''),
                );


        }
        $ret = array('current_dir_path' => $dir_publicupload , 'current_url' => '/' . substr($dir_publicupload,2), 'file_list' => $filesArray, 'moveup_dir_path' => '', 'total_count' => count($filesArray));
        echo json_encode($ret);

 

相关标签: kindeditor thinkphp

上一篇: flex 整合java spring

下一篇: