markyoung1984 Posted January 26, 2009 Share Posted January 26, 2009 I have the following code: $temp1 = 'images\prodinitial\copimage.jpg'; $temp2 = 'images\prodinitial\copimage_1.jpg'; rename($temp1,$temp2); Even if I try double back slash (to account for the escape sequence), I still get the error "[function.rename]: No such file or directory" I'm working on a Windows machine with XAMPP. Its driving me crazy and I can't see whats wrong. The file the command is being launched from is in the same folder as the images folder that the command references. Why is it so hard to simply rename a file? Quote Link to comment https://forums.phpfreaks.com/topic/142498-renaming-a-image-file/ Share on other sites More sharing options...
premiso Posted January 26, 2009 Share Posted January 26, 2009 If the script is in the same file as the images folder, this would work: $temp1 = '\prodinitial\copimage.jpg'; $temp2 = '\prodinitial\copimage_1.jpg'; rename($temp1,$temp2); If you want to use the paths you would need to use the full paths and should look at $_SERVER['DOCUMENT_ROOT'] for that. Quote Link to comment https://forums.phpfreaks.com/topic/142498-renaming-a-image-file/#findComment-746705 Share on other sites More sharing options...
rhodesa Posted January 26, 2009 Share Posted January 26, 2009 try this: if(!is_dir('images')) die("images doesn't exist"); if(!is_dir('images/prodinitial')) die("images/prodinitial doesn't exist"); $temp1 = 'images/prodinitial/copimage.jpg'; $temp2 = 'images/prodinitial/copimage_1.jpg'; rename($temp1,$temp2); Quote Link to comment https://forums.phpfreaks.com/topic/142498-renaming-a-image-file/#findComment-746707 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.