I need help with rename () I need to rename a image. test.com/gallery/I/2005/01/01/test.jpg is an example of where the image is at.. the script is located at. test.com/test/test/rename.php rename('./gallery/I/2005/01/01/test.jpg','./gallery/I/2005/01/01/test2.jpg'); this is not working.. how can i get this to work..
<?php error_reporting( E_ALL ); define( 'DIR_NAME', dirname(__file__) ); $directory = '/gallery/I/2005/01/01/'; $name = 'test.jpg'; $new_name = 'test2.jpg'; /* This assumes same directory, change at your leisure. */ if ( !file_exists($file = DIR_NAME . $directory . $name) ) die( $name . ' does not exist.' ); if ( !rename($file, $new_file = DIR_NAME . $directory . $new_name) ) die( 'Could not rename ' . $name . '.' . PHP_EOL ); if ( !file_exists($new_file) or file_exists($file) ) die( 'Could not rename ' . $name . '.' . PHP_EOL ); PHP: Any errors add this code and give me the output. var_dump(get_defined_vars()); PHP: