Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't rename a file #25

Open
d-forest opened this issue Sep 7, 2016 · 1 comment
Open

Can't rename a file #25

d-forest opened this issue Sep 7, 2016 · 1 comment

Comments

@d-forest
Copy link

d-forest commented Sep 7, 2016

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

@bestmomo
Copy link
Owner

bestmomo commented Sep 7, 2016

Hello

Do you mind make a PR for it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants