rename() only works on the same device, it just changes its name(or "moves" the name to another directory). rename() cannot move the file data from one location to another.
If you want to copy or move the file, you need to do it yourself:
- open the source and destination file
- read() from the source file, write to the destination file in a loop until the end.
- unlink() the source file (only if you want to move it.)