Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript kcfinder已通过URL选择上载目录_Javascript_Php_Jquery_Symfony_Kcfinder - Fatal编程技术网

Javascript kcfinder已通过URL选择上载目录

Javascript kcfinder已通过URL选择上载目录,javascript,php,jquery,symfony,kcfinder,Javascript,Php,Jquery,Symfony,Kcfinder,问题:根据kcfinder的定义,我正在使用此链接打开kcfinder: window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox', ', width=800, height=600'); 在这里,我修改了URL,使其也包含子目录路径,从而使URL变成如下所示http://192.168.212.200/kcfi

问题:根据kcfinder的定义,我正在使用此链接打开kcfinder:

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
在这里,我修改了URL,使其也包含子目录路径,从而使URL变成如下所示
http://192.168.212.200/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
子目录
部分具有要设置的目录名(如果不存在,则创建)。在config.php中,我已经将目录设置为根目录。因此,如果提供了
子目录
,它将在config.php的根目录中创建
子目录。现在我希望这个子目录成为kcfinder的新根目录

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
例如,如果配置中我的
uploadURL
/var/www/html/web/upload/
,则上述URL的新根目录应为
/var/www/html/web/upload/PO/200836/

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
尝试:我已成功为上述URL(或任何URL)创建了目录
/var/www/html/web/upload/PO/200836/
。但是,kcfinder中的根目录仍然设置为
/var/www/html/web/upload/
。因此,当我打开kcfinder时,会在内部创建目录,但根目录仍然设置为config.php中的原始根目录

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
我添加了以下行以将我的根目录更改为我通过URL传递的子目录:

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
$this->config["uploadURL"] .= $_GET['subDir'];
$this->config["uploadDir"] .= $_GET['subDir'];
$this->typeDir = $this->config["uploadDir"] ."/files";
$this->typeURL = $this->config["uploadURL"] ."/files";
我也在github上提出了这个问题,但还没有得到任何回应。我假设我需要做的唯一更改是将根目录设置为显示在正在创建的新目录中,但我不确定应该在哪里执行此操作

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
有解决办法吗

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
PS:我也对任何其他开源web file manager PHP/jQuery解决方案持开放态度,这些解决方案都有办法做到这一点。使用symfony作为框架

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
更新:我已尝试在
upload.php
\uu construct()
中将默认文件夹替换为新修改的文件夹

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
public function __construct() {

    // SET CMS INTEGRATION PROPERTY
    if (isset($_GET['cms']) &&
        $this->checkFilename($_GET['cms']) &&
        is_file("integration/{$_GET['cms']}.php")
    )
        $this->cms = $_GET['cms'];

    // LINKING UPLOADED FILE
    if (count($_FILES))
        $this->file = &$_FILES[key($_FILES)];

    // CONFIG & SESSION SETUP
    $session = new session("conf/config.php");
    $this->config = $session->getConfig();
    $this->session = &$session->values;
    $this->config["uploadURL"] .= $_GET["subDir"];


    // IMAGE DRIVER INIT
    if (isset($this->config['imageDriversPriority'])) {
        $this->config['imageDriversPriority'] =
            text::clearWhitespaces($this->config['imageDriversPriority']);
        $driver = image::getDriver(explode(' ', $this->config['imageDriversPriority']));
        if ($driver !== false)
            $this->imageDriver = $driver;
    }
    if ((!isset($driver) || ($driver === false)) &&
        (image::getDriver(array($this->imageDriver)) === false)
    )
        $this->backMsg("Cannot find any of the supported PHP image extensions!");

    // WATERMARK INIT
    if (isset($this->config['watermark']) && is_string($this->config['watermark']))
        $this->config['watermark'] = array('file' => $this->config['watermark']);

    // GET TYPE DIRECTORY
    $this->types = &$this->config['types'];
    $firstType = array_keys($this->types);
    $firstType = $firstType[0];
    $this->type = (
        isset($_GET['type']) &&
        isset($this->types[$_GET['type']])
    )
        ? $_GET['type'] : $firstType;

    // LOAD TYPE DIRECTORY SPECIFIC CONFIGURATION IF EXISTS
    if (is_array($this->types[$this->type])) {
        foreach ($this->types[$this->type] as $key => $val)
            if (in_array($key, $this->typeSettings))
                $this->config[$key] = $val;
        $this->types[$this->type] = isset($this->types[$this->type]['type'])
            ? $this->types[$this->type]['type'] : "";
    }

    // COOKIES INIT
    $ip = '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
    $ip = '/^' . implode('\.', array($ip, $ip, $ip, $ip)) . '$/';
    if (preg_match($ip, $_SERVER['HTTP_HOST']) ||
        preg_match('/^[^\.]+$/', $_SERVER['HTTP_HOST'])
    )
        $this->config['cookieDomain'] = "";
    elseif (!strlen($this->config['cookieDomain']))
        $this->config['cookieDomain'] = $_SERVER['HTTP_HOST'];
    if (!strlen($this->config['cookiePath']))
        $this->config['cookiePath'] = "/";

    // UPLOAD FOLDER INIT

    // FULL URL
    if (preg_match('/^([a-z]+)\:\/\/([^\/^\:]+)(\:(\d+))?\/(.+)\/?$/',
            $this->config['uploadURL'], $patt)
    ) {
        list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
        $path = path::normalize($path);
        $this->config['uploadURL'] = "$protocol://$domain" . (strlen($port) ? ":$port" : "") . "/$path";
        $this->config['uploadDir'] = strlen($this->config['uploadDir'])
            ? path::normalize($this->config['uploadDir'])
            : path::url2fullPath("/$path");
        $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
        $this->typeURL = "{$this->config['uploadURL']}/{$this->type}";

    // SITE ROOT
    } elseif ($this->config['uploadURL'] == "/") {
        $this->config['uploadDir'] = strlen($this->config['uploadDir'])
            ? path::normalize($this->config['uploadDir'])
            : path::normalize(realpath($_SERVER['DOCUMENT_ROOT']));
        $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
        $this->typeURL = "/{$this->type}";

    // ABSOLUTE & RELATIVE
    } else {
        $this->config['uploadURL'] = (substr($this->config['uploadURL'], 0, 1) === "/")
            ? path::normalize($this->config['uploadURL'])
            : path::rel2abs_url($this->config['uploadURL']);
        $this->config['uploadDir'] = strlen($this->config['uploadDir'])
            ? path::normalize($this->config['uploadDir'])
            : path::url2fullPath($this->config['uploadURL']);
        $this->typeDir = "{$this->config['uploadDir']}/{$this->type}";
        $this->typeURL = "{$this->config['uploadURL']}/{$this->type}";
    }

    // HOST APPLICATIONS INIT
    if (isset($_GET['CKEditorFuncNum'])) {
        $this->opener['name'] = "ckeditor";
        $this->opener['CKEditor'] = array('funcNum' => $_GET['CKEditorFuncNum']);

    } elseif (isset($_GET['opener'])) {
        $this->opener['name'] = $_GET['opener'];

        if ($_GET['opener'] == "tinymce") {
            if (!isset($this->config['_tinyMCEPath']) || !strlen($this->config['_tinyMCEPath']))
                $this->opener['name'] = false;

        } elseif ($_GET['opener'] == "tinymce4") {
            if (!isset($_GET['field']))
                $this->opener['name'] = false;
            else
                $this->opener['TinyMCE'] = array('field' => $_GET['field']);
        }

    } else
        $this->opener['name'] = false;

    // LOCALIZATION
    foreach ($this->langInputNames as $key)
        if (isset($_GET[$key]) &&
            preg_match('/^[a-z][a-z\._\-]*$/i', $_GET[$key]) &&
            file_exists("lang/" . strtolower($_GET[$key]) . ".php")
        ) {
            $this->lang = $_GET[$key];
            break;
        }
    $this->localize($this->lang);

    // IF BROWSER IS ENABLED
    if (!$this->config['disabled']) {

        // TRY TO CREATE UPLOAD DIRECTORY IF NOT EXISTS
        if (!$this->config['disabled'] && !is_dir($this->config['uploadDir']))
            @mkdir($this->config['uploadDir'], $this->config['dirPerms'], true);
        // CHECK & MAKE DEFAULT .htaccess
        if (isset($this->config['_check4htaccess']) &&
            $this->config['_check4htaccess']
        ) {
            $htaccess = "{$this->config['uploadDir']}/.htaccess";
            $original = $this->get_htaccess();
            if (!file_exists($htaccess)) {
                if (!@file_put_contents($htaccess, $original))
                    $this->backMsg("Cannot write to upload folder. {$this->config['uploadDir']}");
            } else {
                if (false === ($data = @file_get_contents($htaccess)))
                    $this->backMsg("Cannot read .htaccess");
                if (($data != $original) && !@file_put_contents($htaccess, $original))
                    $this->backMsg("Incorrect .htaccess file. Cannot rewrite it!");
            }
        }

        // CHECK & CREATE UPLOAD FOLDER
        if (!is_dir($this->typeDir)) {
            if (!mkdir($this->typeDir, $this->config['dirPerms']))
                $this->backMsg("Cannot create {dir} folder.", array('dir' => $this->type));
        } elseif (!is_readable($this->typeDir))
            $this->backMsg("Cannot read upload folder.");
    }
}

这将创建目录和所有内容,但不会将根文件夹设置为新创建的文件夹。文件夹仍设置为默认根目录。

对于在此处查找答案的任何人,我提出了一个替代解决方案,使用了一个名为的Symfony bundle,因为KCFinder在其代码中使用了
$\u GET
变量,我无法在任何地方更改它。事实证明,这个包比kcfinder更好。对于任何使用Symfony的人,我绝对推荐这个

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
在捆绑包中,我所做的只是在它的
ElFinderConfigurationReader.php

window.open('/kcfinder/browse.php?type=files&dir=files/public&subDir=/PO/200836', 'kcfinder_textbox',
            ', width=800, height=600');
$dir="";
parse_str(parse_url($this->requestStack->getCurrentRequest()->server->all()["HTTP_REFERER"])["query"]);
$driverOptions["path"] .= $dir;