filemanager icon indicating copy to clipboard operation
filemanager copied to clipboard

Can't rename a file

Open d-forest opened this issue 9 years ago • 1 comments

Hello,

was working on "how to fix delete, replace a file", and as someone already said, using the commented lines below from getFullPath function make it work :

$dynPart = str_replace($_SERVER['DOCUMENT_ROOT'], '', $this->path_to_files); $full_path = $this->path_to_files . rawurldecode(str_replace ( $dynPart , '' , $path));

The point is, I couldn't rename a file either, and I think I found a tiny mistake, guess was from source too, but calling the rename function also call is_valid_path for both the old name and for the new one.

The issue comes with the new name,

realpath() returns FALSE on failure, e.g. if the file does not exist. (php manual)

, swap both calls substr and realpath the way below fixed it.

$substrpath = substr(realpath($path) . DIRECTORY_SEPARATOR, 0, strlen($this->path_to_files)) . DIRECTORY_SEPARATOR; by $substrpath = realpath(substr($path . DIRECTORY_SEPARATOR, 0, strlen($this->path_to_files))) . DIRECTORY_SEPARATOR;

apparently, everything is working fine with that update..

d-forest avatar Sep 07 '16 08:09 d-forest

Hello

Do you mind make a PR for it ?

bestmomo avatar Sep 07 '16 11:09 bestmomo