Drupal 7 CKEditor and KCFinder, how to upload to private files directory I'm trying to configure KCFinder to upload to the private_files directory that I created outside of the web root. However, it seems like this may not be possible without hacking some library or module files as the KCFinder upload path requires the absolute URL of the website file upload path. I'd rather set this to my private file upload path "/var/www/private_files"
My best guess is that I can hardcode this in /var/www/my_site/sites/all/libraries/kcfinder/core/class/uploader.php but I don't know exactly what to change in this section, or if that will work at all:

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

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

    // ABSOLUTE &amp; RELATIVE
    } else {
        $this-&gt;config['uploadURL'] = (substr($this-&gt;config['uploadURL'], 0, 1) === "/")
            ? path::normalize($this-&gt;config['uploadURL'])
            : path::rel2abs_url($this-&gt;config['uploadURL']);
        $this-&gt;config['uploadDir'] = strlen($this-&gt;config['uploadDir'])
            ? path::normalize($this-&gt;config['uploadDir'])
            : path::url2fullPath($this-&gt;config['uploadURL']);
        $this-&gt;typeDir = "{$this-&gt;config['uploadDir']}/{$this-&gt;type}";
        $this-&gt;typeURL = "{$this-&gt;config['uploadURL']}/{$this-&gt;type}";
    }
I found a solution that works at least in my case. I was on the right path... If you simply want to hardcode an upload path, you just need to configure two things in the uploader.php, the uploadDir where the files will be stored, and the Drupal URL where Drupal can find the private files, in my case:

// UPLOAD FOLDER INIT

    // hardcode private file upload path outside of web root, can't be configured through the UI that I could find
    $this-&gt;config['uploadDir'] = '/var/www/private_files';
    // hardcode the private file url that Drupal needs to be able to access private files internally        
    $this-&gt;config['uploadURL'] = '/system/files';


I know uploadDir already because that's where I've already configured private files to be stored. To find uploadDir, I linked to a private file already located in /var/www/private_files, then double clicked to see the first part of the URL on the dialog that points to where the root of /var/www/private_files is located.

The next thing I had to do was disable htaccess checking in the KCEditor config file (/sites/all/libraries/kceditor/conf/config.php) by setting '_check4htaccess' =&gt; false