rename is a file system function and requires file system paths. But it seems that you are using URI paths.
You can use $_SERVER['DOCUMENT_ROOT'] to add the path to the document root:
rename($_SERVER['DOCUMENT_ROOT'].'/images/old_name.jpg', $_SERVER['DOCUMENT_ROOT'].'/images/new_name.jpg');
Or for more flexibility, use the dirname path to the current __FILE__ file:
rename(dirname(__FILE__).'/images/old_name.jpg', dirname(__FILE__).'/images/new_name.jpg');
Or use relative paths. As you are in / script, .. goes one level up:
rename('../images/old_name.jpg', '../images/new_name.jpg');
Gumbo
source share