Skip to content

Commit

Permalink
Make realpath work for non-existing files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelle-S committed Apr 12, 2016
1 parent b8fd4f8 commit 9cf2317
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion third_party/kcfinder/core/class/uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,14 @@ public function __construct() {
}

protected function realpath($path) {
$rPath = realpath($path);
// PHP's realpath() does not work on files that don't exist, but
// there might be a symlink somewhere in the path so we need to
// check it.
$existing_path = $path;
while (!file_exists($existing_path)) {
$existing_path = dirname($existing_path);
}
$rPath = realpath($existing_path) . substr($path, strlen($existing_path));
if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN")
$rPath = str_replace("\\", "/", $rPath);
return $rPath;
Expand Down

0 comments on commit 9cf2317

Please sign in to comment.