Consider using '/' throughout instead. PHP knows what the directory separator is on the platform it's running on, and will replace '/' with whatever is appropriate when it is given something that is supposed to be a file path.
The reason I suggest '/' is that since '\' is the escape character in PHP strings, if you write a literal [font=monospace]"path\to\file"[/font] string, then PHP will interpret that as having a tab character in it. But then that would show up in the error message....
One other suggestion I can make is to use
rename(realpath($dir), realpath($newpath_dir));
to remove the ".." steps, just in case those are throwing something off (though they shouldn't, in my opinion...).
I've never seen that error myself (and I can't even find it in PHP's source code for either 5.3.0 or 5.3.2 to track it down that way!), so aside from those suggestions and pending any further information I'm at a loss.