Hi everyone. It's been a while since I've needed help with a PHP problem. Hopefully someone here knows what I'm doing wrong because I can't see it.
I am trying to use rename() to rename an image file which is in a subdirectory of a subdirectory the script is running in. The script is running in "/folder" and the images are held in "/folder/images/general"
The script I currently have is:
$old = "./images/general/item2.jpg";
$new = "./images/general/item44.jpg";
if(file_exists($old))
{
rename($old, $new);
echo "yes";
}
else
{
echo "no";
}
The if statement is finding the file as my browser is outputting "yes" however the file is not being renamed. The permissions of the image file are 644 which as far as I am aware, is all it needs to be but I have tried with the permissions set to 666 and even 777. Have I missed something increadibly obvious?
I need the script to be able to rename the image as it's uploaded (was going to have it uploaded, then renamed unless there's a more efficient way?) and to rename files which already exist.
Unfortunately, error logging is disabled on the server this is hosted on and I don't have the necessary access to enable it. Is there maybe something I can put in die() to output the PHP error to the browser just like die(mysql_error());
would output the MySQL error?