Skip to content

Can't rename a file #25

@d-forest

Description

@d-forest

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..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions