javascript - elFinder Connector.php -> Internet Explorer 中的路径

标签 javascript php jquery ajax elfinder

我在connector.php中动态设置路径,它在除Internet Explorer之外的所有浏览器中正常工作。这是我的connector.php代码:

function access($attr, $path, $data, $volume) {
    return strpos(basename($path), '.') === 0       // if file/folder begins with '.' (dot)
        ? !($attr == 'read' || $attr == 'write')    // set read+write to false, other (locked+hidden) set to true
        :  null;                                    // else elFinder decide it itself
}


// Documentation for connector options:
// https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
$opts = array(
    'debug' => true,
    'roots' => array(
        array(
            'driver'        => 'LocalFileSystem',          
            'path'          => '../../pages/path/to/files/'.($_GET['mypath']).'/', 
            'URL'           => '../../pages/path/to/files/'.($_GET['mypath']).'/', 
            'uploadDeny'    => array('all'),               
            'uploadAllow'   => array('image', 'text/plain'),
            'uploadOrder'   => array('deny', 'allow'),      
            'accessControl' => 'access'

        )
    )
);

// run elFinder
$connector = new elFinderConnector(new elFinder($opts));
$connector->run();

基本上发生的情况是,如果您使用任何浏览器(IE 除外),您的根目录将正确设置为 $_GET['mypath'],但如果您使用 IE,则根目录目录设置为 /files/ (该目录仅比所需目录上一级),因此用户可以看到他不应该访问的文件夹。

关于为什么会发生这种情况有什么想法吗?

附注我唯一的理论是,也许 IE JavaScript 引擎发送了不正确的 mypath 变量?

elFinder 代码如下:

<script type="text/javascript" charset="utf-8">
    $().ready(function() {
        var elf = $('#elfinder').elfinder({
            // lang: 'ru',             
            url : 'libraries/elFinder/connector.php', 
            rememberLastDir : false,
            useBrowserHistory : false,
            customData : {mypath : <?php echo json_encode($_GET['CIF']); ?>}
        }).elfinder('instance');            
    });
</script>

页面的实际来源如下所示:

<script type="text/javascript" charset="utf-8">
    $().ready(function() {
        var elf = $('#elfinder').elfinder({
            // lang: 'ru',             
            url : 'libraries/elFinder/connector.php', 
            rememberLastDir : false,
            useBrowserHistory : false,
            customData : {mypath : "mypath_folder"}
        }).elfinder('instance');            
    });
</script>

P.S.S > 我刚刚确认 IE 不会发送 mypath 变量。

有人有什么想法吗?

更新:2016 年 9 月 2 日

今天经过进一步调查,我发现这个脚本有一个非常奇怪的行为:

如果是任何浏览器(IE 除外),则 $_GET['mypath'] 可以正常工作,但在 IE 中 $_GET['mypath'] 则不行设置,但是,如果是 IE,则设置 $_POST['mypath'] 而不是 $_GET['mypath'],但是,在所有其他浏览器中 $_POST['mypath'] 未设置。

我想避免检查浏览器是否为 IE 系列,然后使用 $_POST,如果有其他浏览器,则使用 $_GET

有人有什么建议吗?

答案:

$().ready(function() {
    var elf = $('#elfinder').elfinder({
        // lang: 'ru',             
        url : 'libraries/elFinder/connector.php',
        requestType : 'post',
        rememberLastDir : false,
        useBrowserHistory : false,
        customData : {mypath : <?php echo json_encode($_GET['CIF']); ?>}
    }).elfinder('instance');            
});

如果你强制requestTypepost,那么在所有浏览器中它将始终为post,因此你不必担心检查如果浏览器发布或获取。

最佳答案

$().ready(function() {
    var elf = $('#elfinder').elfinder({
        // lang: 'ru',             
        url : 'libraries/elFinder/connector.php',
        requestType : 'post',
        rememberLastDir : false,
        useBrowserHistory : false,
        customData : {mypath : <?php echo json_encode($_GET['CIF']); ?>}
    }).elfinder('instance');            
});

如果你强制requestTypepost,那么在所有浏览器中它将始终为post,因此你不必担心检查如果浏览器发布或获取。

关于javascript - elFinder Connector.php -> Internet Explorer 中的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35275304/

相关文章:

php - MYSQL 返回总结果

javascript - 在 Label 悬停时显示工具提示?

jquery - 使用 JQUERY 更改输入名称

javascript - javascript 中 php 内爆的异常行为

javascript - 如何在React Native中过滤pokemon

javascript - 执行 javascript 更改 webelement 时找不到变量错误

php - 在 Laravel 4 中声明新位置和新命名空间的位置

php - 使用 PHP 格式化 SQL 时间戳

jquery - 获取 jQuery UI Selectable 的数据属性

javascript - IONIC 2 : How to upload a . docx,远程服务器上的图像文件以及文件到 mysql 数据库的链接